種類
- インスタンスメソッド (456)
- 特異メソッド (38)
- クラス (11)
ライブラリ
- ビルトイン (505)
クラス
- Array (16)
- BasicObject (55)
-
Encoding
:: Converter (22) -
Enumerator
:: Yielder (11) - Exception (11)
-
File
:: Stat (11) - Hash (17)
- Method (32)
- Module (33)
- Object (110)
-
RubyVM
:: InstructionSequence (22) - Thread (38)
-
Thread
:: Backtrace :: Location (11) - TracePoint (6)
- UnboundMethod (11)
モジュール
- Enumerable (88)
キーワード
- ! (11)
- != (11)
- << (11)
- <=> (33)
- == (11)
- BasicObject (11)
-
backtrace
_ locations (33) -
base
_ label (11) - bind (11)
- compile (11)
-
enum
_ for (22) - initialize (11)
-
insert
_ output (11) - inspect (11)
-
instance
_ eval (22) -
instance
_ of? (11) -
instruction
_ sequence (6) -
is
_ a? (11) -
kind
_ of? (11) - max (44)
- methods (11)
- min (44)
- pack (16)
- replacement= (11)
-
report
_ on _ exception (8) -
report
_ on _ exception= (8) -
super
_ method (10) -
to
_ enum (22) -
to
_ h (17) -
to
_ s (11) -
undef
_ method (11)
検索結果
先頭5件
-
Module
# <(other) -> bool | nil (26142.0) -
比較演算子。self が other の子孫である場合、 true を返します。 self が other の先祖か同一のクラス/モジュールである場合、false を返します。
...t[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
end
class Qux
end
p Bar < Foo # => true
p Baz < Bar # => true
p Baz < Foo # => true
p Baz < Qux # => nil
p Baz > Qux # => nil
p Foo < Object.new # => in `<': compared with non class/module (TypeError)
//}... -
RubyVM
:: InstructionSequence . new(source , file = nil , path = nil , line = 1 , options = nil) -> RubyVM :: InstructionSequence (23107.0) -
引数 source で指定した Ruby のソースコードを元にコンパイル済みの RubyVM::InstructionSequence オブジェクトを作成して返します。
...かで指定します。詳細は
RubyVM::InstructionSequence.compile_option= を参照
してください。
RubyVM::InstructionSequence.compile("a = 1 + 2")
# => <RubyVM::InstructionSequence:<compiled>@<compiled>>
@see RubyVM::InstructionSequence.compile_file... -
File
:: Stat # <=>(o) -> Integer | nil (14130.0) -
ファイルの最終更新時刻を比較します。self が other よりも 新しければ正の数を、等しければ 0 を古ければ負の数を返します。 比較できない場合は nil を返します。
...fp1 = Tempfile.open("first")
fp1.print "古い方\n"
sleep(1)
fp2 = Tempfile.open("second")
fp2.print "新しい方\n"
p File::Stat.new(fp1.path) <=> File::Stat.new(fp2.path) #=> -1
p File::Stat.new(fp2.path) <=> File::Stat.new(fp1.path) #=> 1
p File::Stat.new(fp1.path) <=> fp2.path #=> nil
//}... -
Enumerator
:: Yielder # <<(object) -> () (14122.0) -
Enumerator.new で使うメソッドです。
...merator.new で使うメソッドです。
生成された Enumerator オブジェクトの each メソッドを呼ぶと
Enumerator::Yielder オブジェクトが渡されたブロックが実行され、
ブロック内の << が呼ばれるたびに each に渡されたブロックが
<< に渡......された値とともに繰り返されます。
//emlist[例][ruby]{
enum = Enumerator.new do |y|
y << 1
y << 2
y << 3
end
enum.each do |v|
p v
end
# => 1
# 2
# 3
//}... -
Module
# <=>(other) -> Integer | nil (14112.0) -
self と other の継承関係を比較します。
...のクラスやモジュール
//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
end
class Qux
end
p Bar <=> Foo # => -1
p Baz <=> Bar # => -1
p Baz <=> Foo # => -1
p Baz <=> Qux # => nil
p Qux <=> Baz # => nil
p Baz <=> Object.new # => nil
//}... -
Object
# <=>(other) -> 0 | nil (14112.0) -
self === other である場合に 0 を返します。そうでない場合には nil を返します。
...self === other である場合に 0 を返します。そうでない場合には nil を返します。
//emlist[例][ruby]{
a = Object.new
b = Object.new
a <=> a # => 0
a <=> b # => nil
//}
@see Object#===... -
Thread
. report _ on _ exception=(newstate) (8112.0) -
真の時は、いずれかのスレッドが例外によって終了した時に、その内容を $stderr に報告します。
...ルトは false です。
Thread.new { 1.times { raise } }
は $stderr に以下のように出力します:
#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `block in <main>'
1: from -e:1:in `times......なかったりするかもしれません。
スレッドごとに設定する方法は Thread#report_on_exception= を参照してください。
@param newstate スレッド実行中に例外発生した場合、その内容を報告するかどうかを true か false で指定します。......ォルトは true です。
Thread.new { 1.times { raise } }
は $stderr に以下のように出力します:
#<Thread:...> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
2: from -e:1:in `block in <main>'
1: from -e:1:in `tim... -
Array
# pack(template , buffer: String . new) -> String (8107.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...を扱うときには
n, N, v, V を用います。
強制的にエンディアンを指定したいときは、
リトルエンディアンなら < を、
ビッグエンディアンなら >
を後ろにつけます。! と組み合わせることも可能です。
まとめると以下のよう......析などに適切)
//emlist{
S>: big endian unsigned 16bit(nと同じ)
s>: big endian int16_t
s!>: big endian signed short
l<: little endian int32_t
l!<: little endian signed long
//}
=== 各テンプレート文字の説明
説明中、Array#pack と String#unpack で違いのある......sgn * Inf # ±∞ (positive/negative infinity)
else
NaN # 非数 (not a number)
end
else
fra += 1 << 23 # ゲタ
sgn * fra * 2**(exp-127-23) # 正規化数 (normalized number)
end
//}
: G
ビッグエンディアンの倍精... -
Enumerable
# max {|a , b| . . . } -> object | nil (8060.0) -
ブロックの評価結果で各要素の大小判定を行い、最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。
...します。
引数を指定する形式では、空の配列を返します。
ブロックの値は、a > b のとき正、
a == b のとき 0、a < b のとき負の整数を、期待しています。
該当する要素が複数存在する場合、どの要素を返すかは不定です。
@......ge = age
end
end
people = [
Person.new("sato", 55),
Person.new("sato", 33),
Person.new("sato", 11),
Person.new("suzuki", 55),
Person.new("suzuki", 33),
Person.new("suzuki", 11),
Person.new("tanaka", 55),
Person.new("tanaka", 33),
Person.new("tanaka", 11)
]
# 年齢が最大、......が最小
people.max { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => #<Person:0x007fc54b0240a0 @name="sato", @age=55>
people.max(2) { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => [#<Person:0x007fc54b0240a0 @name="sato", @age=55>, #<Person:0x007fc54c033ea0 @name="suzu... -
Enumerable
# max(n) {|a , b| . . . } -> Array (8060.0) -
ブロックの評価結果で各要素の大小判定を行い、最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。
...します。
引数を指定する形式では、空の配列を返します。
ブロックの値は、a > b のとき正、
a == b のとき 0、a < b のとき負の整数を、期待しています。
該当する要素が複数存在する場合、どの要素を返すかは不定です。
@......ge = age
end
end
people = [
Person.new("sato", 55),
Person.new("sato", 33),
Person.new("sato", 11),
Person.new("suzuki", 55),
Person.new("suzuki", 33),
Person.new("suzuki", 11),
Person.new("tanaka", 55),
Person.new("tanaka", 33),
Person.new("tanaka", 11)
]
# 年齢が最大、......が最小
people.max { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => #<Person:0x007fc54b0240a0 @name="sato", @age=55>
people.max(2) { |x, y| (x.age <=> y.age).nonzero? || y.name <=> x.name }
# => [#<Person:0x007fc54b0240a0 @name="sato", @age=55>, #<Person:0x007fc54c033ea0 @name="suzu...