種類
- インスタンスメソッド (1134)
- モジュール関数 (484)
- 特異メソッド (86)
- 変数 (29)
- 定数 (22)
クラス
- Array (558)
- Complex (11)
- Data (4)
- Enumerator (11)
- File (16)
- Float (19)
- Integer (36)
- Module (66)
- Object (22)
- Range (194)
- Rational (55)
- Regexp (11)
- String (11)
- SystemCallError (33)
- UnboundMethod (11)
モジュール
- Enumerable (132)
- Kernel (161)
- Marshal (66)
- Math (297)
- ObjectSpace (11)
キーワード
-
$ @ (11) -
$ SAFE (7) -
$ ~ (11) - & (11)
- * (22)
- ** (11)
- + (11)
- - (11)
- < (11)
- <= (11)
- =~ (22)
- >= (11)
- Array (11)
- Float (11)
- Hash (11)
- Integer (11)
-
MAJOR
_ VERSION (11) -
MINOR
_ VERSION (11) - String (11)
- [] (33)
-
absolute
_ path? (5) - acos (11)
- acosh (11)
- asin (11)
- asinh (11)
- at (11)
- atan (11)
- atan2 (11)
- atanh (11)
- begin (11)
- bind (11)
- bsearch (44)
- cbrt (11)
- ceil (11)
- coerce (11)
- combination (22)
- cos (11)
- cosh (11)
-
count
_ objects (11) - cycle (22)
- define (4)
-
define
_ method (44) -
delete
_ at (11) - dig (9)
- dump (22)
- dup (3)
- each (22)
- end (11)
- erf (11)
- erfc (11)
- exp (11)
- fail (33)
- feed (11)
- fetch (33)
- first (44)
- flatten (11)
- flatten! (11)
- floor (11)
- freeze (5)
- frexp (11)
- gamma (11)
- hypot (11)
-
initialize
_ copy (11) - insert (11)
- intersection (5)
- join (22)
- last (44)
- ldexp (11)
- lgamma (11)
- load (11)
- log (22)
- log10 (11)
- log2 (11)
- max (86)
- min (86)
- new (33)
- permutation (22)
- pop (22)
- pow (22)
- putc (11)
- raise (33)
-
repeated
_ combination (22) -
repeated
_ permutation (22) - replace (11)
- restore (11)
- rotate (11)
- rotate! (11)
- round (30)
- sample (44)
- shift (22)
- sin (11)
-
singleton
_ class (11) - sinh (11)
- sort (22)
- sqrt (11)
- sum (38)
- tan (11)
- tanh (11)
-
to
_ i (11) - transpose (11)
- truncate (11)
-
try
_ convert (3) - zip (22)
- | (11)
検索結果
先頭5件
-
Module
# >(other) -> bool | nil (18144.0) -
比較演算子。 self が other の先祖である場合、true を返します。 self が other の子孫か同一クラスである場合、false を返します。
...@raise TypeError other がクラスやモジュールではない場合に発生します。
@see Module#<
//emlist[例][ruby]{
module Awesome; end
module Included
include Awesome
end
module Prepended
prepend Awesome
end
Included.ancestors # => [Included, Awesome]
Awesome > Included # => true......Included > Awesome # => false
Prepended.ancestors # => [Awesome, Prepended]
Awesome > Prepended # => true
Prepended > Awesome # => false
Awesome > Awesome # => false
Awesome > Object # => nil
//}... -
Module
# >=(other) -> bool | nil (6108.0) -
比較演算子。self が other の先祖か同一クラスである場合、 true を返します。 self が other の子孫である場合、false を返します。
...raise TypeError other がクラスやモジュールではない場合に発生します。
@see Module#<
//emlist[例][ruby]{
module Foo; end
module Bar
include Foo
end
module Baz
prepend Foo
end
Bar.ancestors # => [Bar, Foo]
Foo >= Bar # => true
Bar >= Foo # => false
Baz.ancestors # => [Fo......o, Baz]
Foo >= Baz # => true
Baz >= Foo # => false
Foo >= Foo # => true
Foo >= Object # => nil
//}... -
UnboundMethod
# bind(obj) -> Method (138.0) -
self を obj にバインドした Method オブジェクトを生成して返します。
...@raise TypeError objがbindできないオブジェクトである場合に発生します
//emlist[例][ruby]{
# クラスのインスタンスメソッドの UnboundMethod の場合
class Foo
def foo
"foo"
end
end
# UnboundMethod `m' を生成
p m = Foo.instance_method(:foo) # => #<Unbo......Foo#foo>
# Foo のインスタンスをレシーバとする Method オブジェクトを生成
p m.bind(Foo.new) # => #<Method: Foo#foo>
# Foo のサブクラス Bar のインスタンスをレシーバとする Method
class Bar < Foo
end
p m.bind(Bar.new) # => #<Meth......od: Bar(Foo)#foo>
# モジュールのインスタンスメソッドの UnboundMethod の場合
module Foo
def foo
"foo"
end
end
# UnboundMethod `m' を生成
p m = Foo.instance_method(:foo) # => #<UnboundMethod: Foo#foo>
# Foo をインクルードしたクラス Bar のインスタン... -
SystemCallError
. new(errno) -> SystemCallError (127.0) -
整数 errno に対応する Errno::EXXX オブジェクトを生成して返します。
...コード
@raise TypeError errno を整数に変換できないときに発生します。
例:
p SystemCallError.new("message", 2)
# => #<Errno::ENOENT: No such file or directory - message>
p SystemCallError.new(2)
# => #<Errno::ENOENT: No such file or directory>
p SystemCallErr......or.new(256)
# => #<SystemCallError: Unknown error 256>... -
SystemCallError
. new(error _ message , errno) -> SystemCallError (127.0) -
整数 errno に対応する Errno::EXXX オブジェクトを生成して返します。
...コード
@raise TypeError errno を整数に変換できないときに発生します。
例:
p SystemCallError.new("message", 2)
# => #<Errno::ENOENT: No such file or directory - message>
p SystemCallError.new(2)
# => #<Errno::ENOENT: No such file or directory>
p SystemCallErr......or.new(256)
# => #<SystemCallError: Unknown error 256>... -
Kernel
. # Integer(arg , base = 0) -> Integer (126.0) -
引数を整数(Fixnum,Bignum)に変換した結果を返します。
...した場合に発生します。
@raise TypeError メソッド to_int, to_i を持たないオブジェクトを引数に指定したか、to_int, to_i
が整数(Integerのサブクラス)を返さなかった場合に発生します。
@raise TypeError 引数に nil を指定した場合に発......#=> 4
p Integer(4_000) #=> 4000
p Integer(9.88) #=> 9
p Integer(nil) # can't convert nil into Integer (TypeError)
p Integer(Object.new) # cannot convert Object into Integer (TypeError)
p Integer("10") #=> 10
p Integer("10", 2) #=> 2
p Integer("0d10") #=> 10
p I......nteger("010") #=> 8
p Integer("0o10") #=> 8
p Integer("0x10") #=> 16
p Integer("0b10") #=> 2
p Integer(" \n10\t ") #=> 10 # 先頭と末尾の空白類は無視される
p Integer("1\n0") # `Integer': invalid value for Integer: "1\n0" (ArgumentError)
p Integer("hoge") # `Int... -
Kernel
. # Integer(arg , base = 0 , exception: true) -> Integer | nil (126.0) -
引数を整数(Fixnum,Bignum)に変換した結果を返します。
...した場合に発生します。
@raise TypeError メソッド to_int, to_i を持たないオブジェクトを引数に指定したか、to_int, to_i
が整数(Integerのサブクラス)を返さなかった場合に発生します。
@raise TypeError 引数に nil を指定した場合に発......#=> 4
p Integer(4_000) #=> 4000
p Integer(9.88) #=> 9
p Integer(nil) # can't convert nil into Integer (TypeError)
p Integer(Object.new) # cannot convert Object into Integer (TypeError)
p Integer("10") #=> 10
p Integer("10", 2) #=> 2
p Integer("0d10") #=> 10
p I......nteger("010") #=> 8
p Integer("0o10") #=> 8
p Integer("0x10") #=> 16
p Integer("0b10") #=> 2
p Integer(" \n10\t ") #=> 10 # 先頭と末尾の空白類は無視される
p Integer("1\n0") # `Integer': invalid value for Integer: "1\n0" (ArgumentError)
p Integer("hoge") # `Int... -
Object
# initialize _ copy(obj) -> object (126.0) -
(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。
...を返すだけのメソッドです。
initialize_copy という名前のメソッドは
自動的に private に設定されます。
@raise TypeError レシーバが freeze されているか、obj のクラスがレシーバ
のクラスと異なる場合に発生します。
@see Object#cl......)
#=> instance variables: #<Object:0x4019c9d4>
# tainted?: false
# singleton methods: #<NoMethodError: ...>
check obj.dup
#=> instance variables: #<Object:0x4019c9c0 @foo=1>
# tainted?: true
# singleton methods: #<NoMethodError: ...>
check obj.......clone
#=> instance variables: #<Object:0x4019c880 @foo=1>
# tainted?: true
# singleton methods: :bar
//}......=> instance variables: #<Object:0x4019c9d4>
# singleton methods: #<NoMethodError: ...>
check obj.dup
#=> instance variables: #<Object:0x4019c9c0 @foo=1>
# singleton methods: #<NoMethodError: ...>
check obj.clone
#=> instance variables: #<Object:0x4019c880 @foo=1>... -
Data
. define(*args) -> Class (120.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # => "Fred"
p fred.age # => 5
//}
メンバの値を書き換えることはできません。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
fred.age = 6 # => NoMethodError
//}
メンバを持たないサブク......se(body)
body
in HTTPFetcher::NotFound
:NotFound
end
end
p fetch("http://example.com/") # => "Current time is 2023-01-10 10:00:53 +0900"
p fetch("http://example.com/404") # => :NotFound
//}
@param args 値オブジェクトのクラスを定義するための可変長引数。Symb......t[例][ruby]{
Customer = Data.define(:name, :address) do
def greeting
"Hello #{name}!"
end
end
p Customer.new("Dave", "123 Main").greeting # => "Hello Dave!"
//}
なお、Dataのサブクラスのインスタンスを生成する際にオプション引数を使用したいときは、
init... -
Data
. define(*args) {|subclass| block } -> Class (120.0) -
Data クラスに新しいサブクラスを作って、それを返します。
...(:name, :age)
fred = Dog.new("Fred", 5)
p fred.name # => "Fred"
p fred.age # => 5
//}
メンバの値を書き換えることはできません。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
fred = Dog.new("Fred", 5)
fred.age = 6 # => NoMethodError
//}
メンバを持たないサブク......se(body)
body
in HTTPFetcher::NotFound
:NotFound
end
end
p fetch("http://example.com/") # => "Current time is 2023-01-10 10:00:53 +0900"
p fetch("http://example.com/404") # => :NotFound
//}
@param args 値オブジェクトのクラスを定義するための可変長引数。Symb......t[例][ruby]{
Customer = Data.define(:name, :address) do
def greeting
"Hello #{name}!"
end
end
p Customer.new("Dave", "123 Main").greeting # => "Hello Dave!"
//}
なお、Dataのサブクラスのインスタンスを生成する際にオプション引数を使用したいときは、
init... -
Enumerable
# max {|a , b| . . . } -> object | nil (120.0) -
ブロックの評価結果で各要素の大小判定を行い、最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。
...ブロックの値は、a > b のとき正、
a == b のとき 0、a < b のとき負の整数を、期待しています。
該当する要素が複数存在する場合、どの要素を返すかは不定です。
@param n 取得する要素数。
@raise TypeError ブロックが整数以......{ |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="suzuki", @age=55>]
//}... -
Enumerable
# max(n) {|a , b| . . . } -> Array (120.0) -
ブロックの評価結果で各要素の大小判定を行い、最大の要素、もしくは最大の n 要素が入った降順の配列を返します。 引数を指定しない形式では要素が存在しなければ nil を返します。 引数を指定する形式では、空の配列を返します。
...ブロックの値は、a > b のとき正、
a == b のとき 0、a < b のとき負の整数を、期待しています。
該当する要素が複数存在する場合、どの要素を返すかは不定です。
@param n 取得する要素数。
@raise TypeError ブロックが整数以......{ |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="suzuki", @age=55>]
//}...