別のキーワード
種類
- インスタンスメソッド (745)
- モジュール関数 (87)
- クラス (48)
- 特異メソッド (24)
- オブジェクト (12)
クラス
- Array (10)
- BasicObject (72)
- Enumerator (48)
-
Enumerator
:: Lazy (48) - Method (92)
- Module (144)
- NameError (24)
- NoMethodError (12)
- Object (216)
- Proc (12)
- Regexp (24)
- Thread (12)
- TracePoint (7)
- UnboundMethod (24)
オブジェクト
- main (24)
キーワード
- === (8)
- BasicObject (12)
- Method (12)
- NameError (12)
- NoMethodError (12)
- [] (24)
- args (12)
-
bind
_ call (12) - call (24)
-
class
_ exec (12) -
define
_ method (24) -
define
_ singleton _ method (24) - dig (10)
- dump (24)
- each (48)
-
enum
_ for (48) - eval (24)
- inspect (12)
-
instance
_ eval (24) -
instance
_ methods (12) - lambda (13)
- main (12)
- match (24)
- method (12)
-
method
_ missing (12) - methods (12)
-
module
_ exec (12) - name (12)
- parameters (43)
-
private
_ instance _ methods (12) -
private
_ methods (12) - proc (14)
-
protected
_ instance _ methods (12) -
protected
_ methods (12) - public (48)
-
public
_ instance _ method (12) -
public
_ instance _ methods (12) -
public
_ method (12) -
public
_ methods (12) - receiver (12)
-
require
_ relative (12) -
respond
_ to? (12) -
respond
_ to _ missing? (12) - send (24)
-
singleton
_ method _ added (12) -
singleton
_ method _ removed (12) -
singleton
_ method _ undefined (12) -
singleton
_ methods (12) -
to
_ enum (48) -
to
_ s (24)
検索結果
先頭5件
-
BasicObject
# instance _ eval(expr , filename = "(eval)" , lineno = 1) -> object (3122.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
.../def#nest_method を参照してください。
BasicObject を継承して作ったクラス内で instance_eval する場合はトップレベルの定数や Kernel モジュールに定義されているメソッドは見えません。
これは、トップレベルの定数が Object 以下に......imeError)
//}
//emlist[例][ruby]{
class Bar < BasicObject
def call1
instance_eval("::ENV.class")
end
def call2
instance_eval("ENV.class")
end
end
bar = Bar.new
bar.call1 # => Object
bar.call2 # raise NameError
//}
@see Module#module_eval, Kernel.#eval, BasicObject#instance_exec... -
UnboundMethod
# bind _ call(recv , *args) -> object (3116.0) -
self を recv に bind して args を引数として呼び出します。
...self を recv に bind して args を引数として呼び出します。
self.bind(recv).call(*args) と同じ意味です。
//emlist[][ruby]{
puts Kernel.instance_method(:inspect).bind_call(BasicObject.new) # => #<BasicObject:0x000055c65e8ea7b8>
//}
@see UnboundMethod#bind, Method#call... -
UnboundMethod
# bind _ call(recv , *args) { . . . } -> object (3116.0) -
self を recv に bind して args を引数として呼び出します。
...self を recv に bind して args を引数として呼び出します。
self.bind(recv).call(*args) と同じ意味です。
//emlist[][ruby]{
puts Kernel.instance_method(:inspect).bind_call(BasicObject.new) # => #<BasicObject:0x000055c65e8ea7b8>
//}
@see UnboundMethod#bind, Method#call... -
NoMethodError
# args -> [object] (3115.0) -
メソッド呼び出しに使われた引数を配列で返します。
...メソッド呼び出しに使われた引数を配列で返します。
例:
begin
foobar(1,2,3)
rescue NoMethodError
p $!
p $!.name
p $!.args
end
# => #<NoMethodError: undefined method `foobar' for main:Object>
:foobar
[1, 2, 3]... -
UnboundMethod
# parameters -> [object] (3115.0) -
UnboundMethod オブジェクトの引数の情報を返します。
...UnboundMethod オブジェクトの引数の情報を返します。
詳しくは Method#parameters を参照してください。
@see Proc#parameters, Method#parameters... -
Enumerator
# each { . . . } -> object (128.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...rld"]
obj = Object.new
def obj.each_arg(a, b=:b, *rest)
yield a
yield b
yield rest
:method_returned
end
enum = obj.to_enum :each_arg, :a, :x
enum.each.to_a # => [:a, :x, []]
enum.each.equal?(enum) # => true
enum.each { |elm| elm } # => :method_returned......enum.each(:y, :z).to_a # => [:a, :x, [:y, :z]]
enum.each(:y, :z).equal?(enum) # => false
enum.each(:y, :z) { |elm| elm } # => :method_returned
//}... -
Enumerator
# each(*args) { . . . } -> object (128.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...rld"]
obj = Object.new
def obj.each_arg(a, b=:b, *rest)
yield a
yield b
yield rest
:method_returned
end
enum = obj.to_enum :each_arg, :a, :x
enum.each.to_a # => [:a, :x, []]
enum.each.equal?(enum) # => true
enum.each { |elm| elm } # => :method_returned......enum.each(:y, :z).to_a # => [:a, :x, [:y, :z]]
enum.each(:y, :z).equal?(enum) # => false
enum.each(:y, :z) { |elm| elm } # => :method_returned
//}... -
TracePoint
# parameters -> [object] (125.0) -
現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。 フォーマットは Method#parameters と同じです。
...現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。
フォーマットは Method#parameters と同じです。
@raise RuntimeError :call、:return、:b_call、:b_return、:c_call、:c_return
イベントのためのイベン......トフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(a, b = 2)
end
TracePoint.new(:call) do |tp|
p tp.parameters # => a], [:opt, :b
end.enable do
foo(1)
end
//}
@see Method#parameters, UnboundMethod#parameters, Proc#parameters... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) -> Enumerator :: Lazy (122.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (122.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が...