るりまサーチ

最速Rubyリファレンスマニュアル検索!
125件ヒット [1-100件を表示] (0.037秒)

別のキーワード

  1. _builtin ord
  2. string ord
  3. integer ord
  4. ord
  5. ord _builtin

クラス

キーワード

検索結果

<< 1 2 > >>

Integer#ord -> Integer (18133.0)

自身を返します。

...自身を返します。

//emlist[][ruby]{
10.ord #=> 10
# String#ord
?a.ord #=> 97
//}

@
see String#ord...

String#ord -> Integer (18127.0)

文字列の最初の文字の文字コードを整数で返します。

...の文字コードを整数で返します。

self が空文字列のときは例外を発生します。

@
return 文字コードを表す整数
@
raise ArgumentError self の長さが 0 のとき発生

//emlist[例][ruby]{
p "a".ord # => 97
//}

@
see Integer#chr, String#chr...

Hash.ruby2_keywords_hash?(hash) -> bool (6108.0)

Module#ruby2_keywordsやProc#ruby2_keywordsによる ruby2_keywords フラグが設定されているかどうかを返します。

...Module#ruby2_keywordsやProc#ruby2_keywordsによる
ruby2_keywords フラグが設定されているかどうかを返します。

このメソッドはデバッグや調査、シリアライゼーションのために本当に必要な場合のために
用意されていて、普通のプログ...
...れていません。

ruby 2.7.1 で追加されたため、ruby 2.7.0 では定義されていません。

//emlist[][ruby]{
ruby2_keywords def foo(*args)
Hash.ruby2_keywords_hash?(args.last)
end
foo(k: 1) # => true
foo({k: 1}) # => false
//}

@
see Module#ruby2_keywords, Proc#ruby2_keywords...

Struct.new(*args, keyword_init: false) -> Class (123.0)

Struct クラスに新しいサブクラスを作って、それを返します。

...です。

@
param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@
param keyword_init true を指定すると、キーワード引数で初期化する構造体を定義します。

//emlist[例][ruby]{
Point = Struct.new(:x, :y, keyword_init: t...
...rue) # => Point(keyword_init: true)
Point.new(x: 1, y: 2) # => #<struct Point x=1, y=2>
Point.new(x: 1) # => #<struct Point x=1, y=nil>
Point.new(y: 2) # => #<struct Point x=nil, y=2>
Point.new(z: 3) # ArgumentError (unknown keywords: z)
//}


=== 第一引数が String の場合
a...
...ing # => "Hello Dave!"
//}

Structをカスタマイズする場合はこの方法が推奨されます。無名クラスのサブ
クラスを作成する方法でカスタマイズする場合は無名クラスが使用されなくなっ
てしまうことがあるためです。

@
see Class.new...

Struct.new(*args, keyword_init: false) {|subclass| block } -> Class (123.0)

Struct クラスに新しいサブクラスを作って、それを返します。

...です。

@
param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@
param keyword_init true を指定すると、キーワード引数で初期化する構造体を定義します。

//emlist[例][ruby]{
Point = Struct.new(:x, :y, keyword_init: t...
...rue) # => Point(keyword_init: true)
Point.new(x: 1, y: 2) # => #<struct Point x=1, y=2>
Point.new(x: 1) # => #<struct Point x=1, y=nil>
Point.new(y: 2) # => #<struct Point x=nil, y=2>
Point.new(z: 3) # ArgumentError (unknown keywords: z)
//}


=== 第一引数が String の場合
a...
...ing # => "Hello Dave!"
//}

Structをカスタマイズする場合はこの方法が推奨されます。無名クラスのサブ
クラスを作成する方法でカスタマイズする場合は無名クラスが使用されなくなっ
てしまうことがあるためです。

@
see Class.new...

絞り込み条件を変える

Struct.new(*args, keyword_init: nil) -> Class (123.0)

Struct クラスに新しいサブクラスを作って、それを返します。

...ょう。
したがって、メンバ名は Symbol で指定するのが無難です。

@
param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@
param keyword_init true を指定すると、キーワード引数で初期化する構造体を定...
...uct.new(:x, :y, keyword_init: true) # => Point(keyword_init: true)
Point.new(x: 1, y: 2) # => #<struct Point x=1, y=2>
Point.new(x: 1) # => #<struct Point x=1, y=nil>
Point.new(y: 2) # => #<struct Point x=nil, y=2>
Point.new(z: 3) # ArgumentError (unknown keywords: z)
//}

//emlist...
...# warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).

# keyword_init: falseを指定すると警告は出ない
Point2 = Struct.new(:x, :y, keyword_init: false)
Point2.new(x: 1, y...
...ょう。
したがって、メンバ名は Symbol で指定するのが無難です。

@
param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@
param keyword_init 構造体クラスのインスタンスを生成する際に、キーワード引...
...nil>
Point1.new(y: 2) # => #<struct Point1 x=nil, y=2>
Point1.new(x: 1, y: 2, z: 3) # => ArgumentError (unknown keywords: z)

Point2 = Struct.new(:x, :y, keyword_init: nil)
Point2.new(1, 2) # => #<struct Point2 x=1, y=2>
Point2.new(x: 1, y: 2) # => #<struct Point2 x=1,...
...nil>
Point2.new(y: 2) # => #<struct Point2 x=nil, y=2>
Point2.new(x: 1, y: 2, z: 3) # => ArgumentError (unknown keywords: z)

Point3 = Struct.new(:x, :y, keyword_init: true)
Point3.new(1, 2) # => wrong number of arguments (given 2, expected 0) (ArgumentError)
Point3.new(x: 1,...

Struct.new(*args, keyword_init: nil) {|subclass| block } -> Class (123.0)

Struct クラスに新しいサブクラスを作って、それを返します。

...ょう。
したがって、メンバ名は Symbol で指定するのが無難です。

@
param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@
param keyword_init true を指定すると、キーワード引数で初期化する構造体を定...
...uct.new(:x, :y, keyword_init: true) # => Point(keyword_init: true)
Point.new(x: 1, y: 2) # => #<struct Point x=1, y=2>
Point.new(x: 1) # => #<struct Point x=1, y=nil>
Point.new(y: 2) # => #<struct Point x=nil, y=2>
Point.new(z: 3) # ArgumentError (unknown keywords: z)
//}

//emlist...
...# warning: Passing only keyword arguments to Struct#initialize will behave differently from Ruby 3.2. Please use a Hash literal like .new({k: v}) instead of .new(k: v).

# keyword_init: falseを指定すると警告は出ない
Point2 = Struct.new(:x, :y, keyword_init: false)
Point2.new(x: 1, y...
...ょう。
したがって、メンバ名は Symbol で指定するのが無難です。

@
param args 構造体を定義するための可変長引数。String または Symbol を指定します。
@
param keyword_init 構造体クラスのインスタンスを生成する際に、キーワード引...
...nil>
Point1.new(y: 2) # => #<struct Point1 x=nil, y=2>
Point1.new(x: 1, y: 2, z: 3) # => ArgumentError (unknown keywords: z)

Point2 = Struct.new(:x, :y, keyword_init: nil)
Point2.new(1, 2) # => #<struct Point2 x=1, y=2>
Point2.new(x: 1, y: 2) # => #<struct Point2 x=1,...
...nil>
Point2.new(y: 2) # => #<struct Point2 x=nil, y=2>
Point2.new(x: 1, y: 2, z: 3) # => ArgumentError (unknown keywords: z)

Point3 = Struct.new(:x, :y, keyword_init: true)
Point3.new(1, 2) # => wrong number of arguments (given 2, expected 0) (ArgumentError)
Point3.new(x: 1,...

Exception#full_message(highlight: true, order: :bottom) -> String (120.0)

例外の整形された文字列を返します。

...引数 highlight と order は 2.5.1 で追加されました。

@
param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。

@
param order :top か :bottom...
...e[1m)\n\e[m"
$stderr = $stdout
p e.full_message # => "test.rb:2:in `<main>': test (RuntimeError)\n"
$stderr = STDERR
p e.full_message # => "\e[1mTraceback \e[m(most recent call last):\ntest.rb:2:in `<main>': \e[1mtest (\e[4;1mRuntimeError\e[m\e[1m)\n\e[m"
end
//}

@
see Exception.to_tty?...
...よる文字装飾がついています。


@
param highlight エスケープシーケンスによる文字装飾をつけるかどうかを指定します。
デフォルト値は Exception.to_tty? の返り値と同じです。

@
param order :top か :bottom で指定する必要...

Encoding::Converter#primitive_convert(source_buffer, destination_buffer) -> Symbol (44.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...になります。

@
param source_buffer 変換元文字列のバッファ
@
param destination_buffer 変換先文字列を格納するバッファ
@
param destination_byteoffset 変換先バッファでのオフセット
@
param destination_bytesize 変換先バッファの容量
@
param options 変換...
...の詳細を指定する定数やハッシュ
@
return 変換結果を表す Symbol

options には以下が指定できます。

: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input...
...redo
when :undefined_conversion
c = ec.primitive_errinfo[3].dup.force_encoding(ec.primitive_errinfo[1])
ec.insert_output('\x{%X:%s}' % [c.ord, c.encoding])
redo
when :incomplete_input
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
when :finished
end
break
end while...

Encoding::Converter#primitive_convert(source_buffer, destination_buffer, destination_byteoffset) -> Symbol (44.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...になります。

@
param source_buffer 変換元文字列のバッファ
@
param destination_buffer 変換先文字列を格納するバッファ
@
param destination_byteoffset 変換先バッファでのオフセット
@
param destination_bytesize 変換先バッファの容量
@
param options 変換...
...の詳細を指定する定数やハッシュ
@
return 変換結果を表す Symbol

options には以下が指定できます。

: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input...
...redo
when :undefined_conversion
c = ec.primitive_errinfo[3].dup.force_encoding(ec.primitive_errinfo[1])
ec.insert_output('\x{%X:%s}' % [c.ord, c.encoding])
redo
when :incomplete_input
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
when :finished
end
break
end while...

絞り込み条件を変える

Encoding::Converter#primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize) -> Symbol (44.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...になります。

@
param source_buffer 変換元文字列のバッファ
@
param destination_buffer 変換先文字列を格納するバッファ
@
param destination_byteoffset 変換先バッファでのオフセット
@
param destination_bytesize 変換先バッファの容量
@
param options 変換...
...の詳細を指定する定数やハッシュ
@
return 変換結果を表す Symbol

options には以下が指定できます。

: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input...
...redo
when :undefined_conversion
c = ec.primitive_errinfo[3].dup.force_encoding(ec.primitive_errinfo[1])
ec.insert_output('\x{%X:%s}' % [c.ord, c.encoding])
redo
when :incomplete_input
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
when :finished
end
break
end while...

Encoding::Converter#primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize, options) -> Symbol (44.0)

エンコーディング変換のためのメソッドの中で、もっとも細かな扱いが可能なメソッドです。

...になります。

@
param source_buffer 変換元文字列のバッファ
@
param destination_buffer 変換先文字列を格納するバッファ
@
param destination_byteoffset 変換先バッファでのオフセット
@
param destination_bytesize 変換先バッファの容量
@
param options 変換...
...の詳細を指定する定数やハッシュ
@
return 変換結果を表す Symbol

options には以下が指定できます。

: hash form
:partial_input => true # source buffer may be part of larger source
:after_output => true # stop conversion after output before input...
...redo
when :undefined_conversion
c = ec.primitive_errinfo[3].dup.force_encoding(ec.primitive_errinfo[1])
ec.insert_output('\x{%X:%s}' % [c.ord, c.encoding])
redo
when :incomplete_input
ec.insert_output(ec.primitive_errinfo[3].dump[1..-2])
when :finished
end
break
end while...

Integer#chr -> String (32.0)

self を文字コードとして見た時に、引数で与えたエンコーディング encoding に対応する文字を返します。

...//}

@
param encoding エンコーディングを表すオブジェクト。Encoding::UTF_8、'shift_jis' など。
@
return 一文字からなる文字列
@
raise RangeError self を与えられたエンコーディングで正しく解釈できない場合に発生します。
@
see String#ord En...
<< 1 2 > >>