395件ヒット
[1-100件を表示]
(0.075秒)
種類
- インスタンスメソッド (322)
- モジュール関数 (40)
- クラス (22)
- 特異メソッド (11)
ライブラリ
- ビルトイン (395)
クラス
- Array (19)
- BasicObject (22)
- Enumerator (66)
-
Enumerator
:: Lazy (11) -
Enumerator
:: Yielder (11) - FrozenError (5)
- Method (28)
- Module (11)
- Object (88)
- Proc (6)
- Regexp (22)
- String (22)
モジュール
- Enumerable (22)
- Kernel (40)
キーワード
- Numeric (11)
- String (11)
- clone (11)
-
define
_ singleton _ method (22) - dup (11)
- each (44)
- extend (11)
- gets (11)
-
initialize
_ copy (11) - inspect (11)
- loop (18)
- match (22)
- methods (11)
- new (11)
- pack (19)
-
prepend
_ features (11) - readline (11)
- receiver (5)
-
singleton
_ method _ removed (11) -
singleton
_ method _ undefined (11) -
singleton
_ methods (11) -
sort
_ by (22) - sum (11)
-
to
_ s (11) - unpack (11)
-
with
_ object (22)
検索結果
先頭5件
-
Enumerator
:: Yielder # <<(object) -> () (26142.0) -
Enumerator.new で使うメソッドです。
...が実行され、
ブロック内の << が呼ばれるたびに 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
//}......クが実行され、
ブロック内の << が呼ばれるたびに 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
//}... -
Method
# <<(callable) -> Proc (26142.0) -
self と引数を合成した Proc を返します。
...y]{
def f(x)
x * x
end
def g(x)
x + x
end
# (3 + 3) * (3 + 3)
p (method(:f) << method(:g)).call(3) # => 36
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, Wor......ld!
Hello, Ruby!
TEXT
pipeline = method(:pp) << WordScanner << File.method(:read)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}
@see Proc#<<, Proc#>>... -
Proc
# <<(callable) -> Proc (26130.0) -
self と引数を合成した Proc を返します。
...(f << g).call(3) # => 36
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = proc { |data| puts "word count: #{data.size}" } << W......ordScanner << File.method(:read)
pipeline.call('testfile') # => word count: 4
//}
@see Method#<<, Method#>>... -
Module
# prepend _ features(mod) -> self (14142.0) -
Module#prepend から呼び出されるメソッドで、 prepend の処理の実体です。このメソッド自体は mod で指定した モジュール/クラスの継承チェインの先頭に self を追加します。
...Module#prepend から呼び出されるメソッドで、
prepend の処理の実体です。このメソッド自体は mod で指定した
モジュール/クラスの継承チェインの先頭に self を追加します。
このメソッドを上書きすることで、prepend の処理を変......m mod prepend を呼び出したモジュール
@return mod が返されます
//emlist[例][ruby]{
class Recorder
RECORDS = []
end
module X
def self.prepend_features(mod)
Recorder::RECORDS << mod
end
end
class A
prepend X
end
class B
include X
end
class C
prepend X
end
Recorde......r::RECORDS # => [A, C]
//}
@see Module#prepend, Module#prepended... -
Object
# extend(*modules) -> self (14142.0) -
引数で指定したモジュールのインスタンスメソッドを self の特異 メソッドとして追加します。
...ス)に機能を追加します
が、extend は、ある特定のオブジェクトだけにモジュールの機能を追加
したいときに使用します。
引数に複数のモジュールを指定した場合、最後
の引数から逆順に extend を行います。
@param modules モ......ule Foo
def a
'ok Foo'
end
end
module Bar
def b
'ok Bar'
end
end
obj = Object.new
obj.extend Foo, Bar
p obj.a #=> "ok Foo"
p obj.b #=> "ok Bar"
class Klass
include Foo
extend Bar
end
p Klass.new.a #=> "ok Foo"
p Klass.b #=> "ok Bar"
//}
extend の機能は、「特異ク......ただしその場合、フック用のメソッド
が Module#extended ではなく Module#included になるという違いがあります。
//emlist[][ruby]{
# obj.extend Foo, Bar とほぼ同じ
class << obj
include Foo, Bar
end
//}
@see Module#extend_object,Module#include,Module#extended... -
Object
# singleton _ methods(inherited _ too = true) -> [Symbol] (8114.0) -
そのオブジェクトに対して定義されている特異メソッド名 (public あるいは protected メソッド) の一覧を返します。
...を返します。
inherited_too が真のときは継承した特異メソッドを含みます。
継承した特異メソッドとは Object#extend によって追加された特異メソッドや、
self がクラスの場合はスーパークラスのクラスメソッド(Classのインスタ......Class.new
class <<Parent
private; def private_class_parent() end
protected; def protected_class_parent() end
public; def public_class_parent() end
end
Foo = Class.new(Parent)
class <<Foo
private; def private_class_foo() end
protected; def protected_class_foo() end
public; de......o() end
end
module Bar
private; def private_bar() end
protected; def protected_bar() end
public; def public_bar() end
end
obj = Foo.new
class <<obj
include Bar
private; def private_self() end
protected; def protected_self() end
public; def public_self() end
end
#... -
Method
# inspect -> String (8084.0) -
self を読みやすい文字列として返します。
...モジュール名、
method は、メソッド名を表します。
//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar
end
end
p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo>
p Bar.new.method(:bar) # => #<Method: Bar#bar>
//}
klass......= ""
class <<obj
def foo
end
end
p obj.method(:foo) # => #<Method: "".foo>
# クラスメソッド(クラスの特異メソッド)
class Foo
def Foo.foo
end
end
p Foo.method(:foo) # => #<Method: Foo.foo>
# スーパークラスのクラスメソッド
class Bar < Foo
end
p Bar.me......thod(:foo) # => #<Method: Bar.foo>
# 以下は(形式1)の出力になる
module Baz
def baz
end
end
class <<obj
include Baz
end
p obj.method(:baz) # => #<Method: Object(Baz)#baz>
//}
@see Object#inspect......ます。
source_location が nil の場合には付きません。
//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar(a, b)
end
end
p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Ba......ruby]{
# オブジェクトの特異メソッド
obj = ""
class <<obj
def foo
end
end
p obj.method(:foo) # => #<Method: "".foo() foo.rb:4>
# クラスメソッド(クラスの特異メソッド)
class Foo
def Foo.foo
end
end
p Foo.method(:foo) # => #<Method: Foo.foo() foo.rb:11>......# スーパークラスのクラスメソッド
class Bar < Foo
end
p Bar.method(:foo) # => #<Method: Bar(Foo).foo() foo.rb:11>
# 以下は(形式1)の出力になる
module Baz
def baz
end
end
class <<obj
include Baz
end
p obj.method(:baz) # => #<Method: String(Baz)#baz() foo.rb:2... -
Method
# to _ s -> String (8084.0) -
self を読みやすい文字列として返します。
...モジュール名、
method は、メソッド名を表します。
//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar
end
end
p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo>
p Bar.new.method(:bar) # => #<Method: Bar#bar>
//}
klass......= ""
class <<obj
def foo
end
end
p obj.method(:foo) # => #<Method: "".foo>
# クラスメソッド(クラスの特異メソッド)
class Foo
def Foo.foo
end
end
p Foo.method(:foo) # => #<Method: Foo.foo>
# スーパークラスのクラスメソッド
class Bar < Foo
end
p Bar.me......thod(:foo) # => #<Method: Bar.foo>
# 以下は(形式1)の出力になる
module Baz
def baz
end
end
class <<obj
include Baz
end
p obj.method(:baz) # => #<Method: Object(Baz)#baz>
//}
@see Object#inspect......ます。
source_location が nil の場合には付きません。
//emlist[例][ruby]{
module Foo
def foo
"foo"
end
end
class Bar
include Foo
def bar(a, b)
end
end
p Bar.new.method(:foo) # => #<Method: Bar(Foo)#foo() test.rb:2>
p Bar.new.method(:bar) # => #<Method: Ba......ruby]{
# オブジェクトの特異メソッド
obj = ""
class <<obj
def foo
end
end
p obj.method(:foo) # => #<Method: "".foo() foo.rb:4>
# クラスメソッド(クラスの特異メソッド)
class Foo
def Foo.foo
end
end
p Foo.method(:foo) # => #<Method: Foo.foo() foo.rb:11>......# スーパークラスのクラスメソッド
class Bar < Foo
end
p Bar.method(:foo) # => #<Method: Bar(Foo).foo() foo.rb:11>
# 以下は(形式1)の出力になる
module Baz
def baz
end
end
class <<obj
include Baz
end
p obj.method(:baz) # => #<Method: String(Baz)#baz() foo.rb:2... -
Object
# methods(include _ inherited = true) -> [Symbol] (8078.0) -
そのオブジェクトに対して呼び出せるメソッド名の一覧を返します。 このメソッドは public メソッドおよび protected メソッドの名前を返します。
...() end
protected; def protected_parent() end
public; def public_parent() end
end
class Foo < Parent
private; def private_foo() end
protected; def protected_foo() end
public; def public_foo() end
end
obj = Foo.new
class <<obj
private; def private_singleton() end......protected; def protected_singleton() end
public; def public_singleton() end
end
# あるオブジェクトの応答できるメソッドの一覧を得る。
p obj.methods(false)
p obj.public_methods(false)
p obj.private_methods(false)
p obj.protected_methods(false)
# 実行結果
[:... -
Array
# pack(template) -> String (8072.0) -
配列の内容を template で指定された文字列にしたがって、 バイナリとしてパックした文字列を返します。
...、整数サイズ非依存 (ネットワークプロトコルなどに適切)
//emlist{
n: big endian unsigned 16bit
N: big endian unsigned 32bit
v: little endian unsigned 16bit
V: little endian unsigned 32bit
//}
: エンディアン依存、整数サイズ依存 (C の構造体などに......ィアンの強制指定(バイナリ解析などに適切)
//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#p......ber)
end
elsif exp == 255
if fra == 0
sgn * Inf # ±∞ (positive/negative infinity)
else
NaN # 非数 (not a number)
end
else
fra += 1 << 23 # ゲタ
sgn * fra * 2**(exp-127-23) # 正規化数 (normalized number)
end
//}...