414件ヒット
[201-300件を表示]
(0.078秒)
ライブラリ
- ビルトイン (366)
-
irb
/ context (12) -
irb
/ ext / history (24) - win32ole (12)
クラス
- BasicObject (48)
- Binding (70)
-
IRB
:: Context (36) - Module (96)
- Object (78)
- Proc (24)
-
RubyVM
:: InstructionSequence (24) - TracePoint (26)
-
WIN32OLE
_ TYPE (12)
キーワード
- binding (12)
-
class
_ eval (24) -
class
_ exec (12) -
default
_ event _ sources (12) -
define
_ method (24) -
eval
_ history (12) -
eval
_ history= (12) -
eval
_ script (7) - evaluate (12)
-
instance
_ eval (24) -
instance
_ exec (12) -
instance
_ variables (12) -
instruction
_ sequence (7) -
local
_ variable _ defined? (12) -
local
_ variable _ get (12) -
local
_ variable _ set (12) -
local
_ variables (11) - method (12)
-
module
_ eval (24) -
module
_ exec (12) - receiver (11)
-
respond
_ to? (12) - self (12)
- send (24)
-
singleton
_ method (12) -
singleton
_ method _ undefined (12) -
source
_ location (12) - taint (6)
-
to
_ a (12)
検索結果
先頭5件
-
Binding
# local _ variable _ defined?(symbol) -> bool (6113.0) -
引数 symbol で指定した名前のローカル変数が定義されている場合に true を、 そうでない場合に false を返します。
...binding.local_variable_defined?(:a) # => true
binding.local_variable_defined?(:b) # => false
end
//}
このメソッドは以下のコードの短縮形です。
//emlist[][ruby]{
binding.eval("defined?(#{symbol}) == 'local-variable'")
//}
@see Binding#local_variable_get, Binding#local_variabl... -
Binding
# local _ variable _ get(symbol) -> object (6113.0) -
引数 symbol で指定した名前のローカル変数に設定された値を返します。
...][ruby]{
def foo
a = 1
binding.local_variable_get(:a) # => 1
binding.local_variable_get(:b) # => NameError
end
//}
このメソッドは以下のコードの短縮形です。
//emlist[][ruby]{
binding.eval("#{symbol}")
//}
@see Binding#local_variable_set, Binding#local_variable_defined?... -
Binding
# local _ variable _ set(symbol , obj) (6113.0) -
引数 symbol で指定した名前のローカル変数に引数 obj を設定します。
...a = 1
bind = binding
bind.local_variable_set(:a, 2) # set existing local variable `a'
bind.local_variable_set(:b, 3) # create new local variable `b'
# `b' exists only in binding
p bind.local_variable_get(:a) # => 2
p bind.local_variable_get(:b) # => 3
p......# => NameError
end
//}
このメソッドは以下のコード(ただし、obj が Ruby のコードで出力される場
合)と同様の動作をします。
//emlist[][ruby]{
binding.eval("#{symbol} = #{obj}")
//}
@see Binding#local_variable_get, Binding#local_variable_defined?... -
Proc
# source _ location -> [String , Integer] | nil (6113.0) -
ソースコードのファイル名と行番号を配列で返します。
...by]{
# /path/to/target.rb を実行
proc {}.source_location # => ["/path/to/target.rb", 1]
proc {}.source_location # => ["/path/to/target.rb", 2]
(eval "proc {}").source_location # => ["(eval)", 1]
method(:p).to_proc.source_location # => nil
//}
@see Method#source_location... -
BasicObject
# instance _ exec(*args) {|*vars| . . . } -> object (6107.0) -
与えられたブロックをレシーバのコンテキストで実行します。
...タに渡す値です。
//emlist[例][ruby]{
class KlassWithSecret
def initialize
@secret = 99
end
end
k = KlassWithSecret.new
# 以下で x には 5 が渡される
k.instance_exec(5) {|x| @secret + x } #=> 104
//}
@see Module#class_exec, Module#module_exec, BasicObject#instance_eval... -
Binding
# receiver -> object (6107.0) -
保持するコンテキスト内での self を返します。
...保持するコンテキスト内での self を返します。
このメソッドは以下のコードと同様の動作をします。
//emlist[][ruby]{
binding.eval("self")
//}... -
Object
# instance _ variables -> [Symbol] (6107.0) -
オブジェクトのインスタンス変数名をシンボルの配列として返します。
...列として返します。
//emlist[][ruby]{
obj = Object.new
obj.instance_eval { @foo, @bar = nil }
p obj.instance_variables
#=> [:@foo, :@bar]
//}
@see Object#instance_variable_get, Kernel.#local_variables, Kernel.#global_variables, Module.constants, Module#constants, Module#class_variables... -
Object
# respond _ to?(name , include _ all = false) -> bool (3131.0) -
オブジェクトがメソッド name を持つとき真を返します。
...indows での Process.fork や GNU/Linux での File.lchmod の
ような NotImplementedError が発生する場合は false を返します。
※ NotImplementedError が発生する場合に false を返すのは
Rubyの組み込みライブラリや標準ライブラリなど、C言語で実装......ッドが定義されていない場合は、Object#respond_to_missing? を呼
び出してその結果を返します。
@param name Symbol または文字列で指定するメソッド名です。
@param include_all private メソッドと protected メソッドを確認の対象に......になります。
//emlist[][ruby]{
class F
def hello
"Bonjour"
end
end
class D
private
def hello
"Guten Tag"
end
end
list = [F.new,D.new]
list.each{|it| puts it.hello if it.respond_to?(:hello)}
#=> Bonjour
list.each{|it| it.instance_eval("puts hello if it.respond_to?(:hello,... -
Object
# send(name , *args) -> object (3125.0) -
オブジェクトのメソッド name を args を引数に して呼び出し、メソッドの実行結果を返します。
...の呼び出し制限
にかかわらず任意のメソッドを呼び出せます。
d:spec/def#limit も参照してください。
public メソッドだけ呼び出せれば良い場合は
Object#public_send を使う方が良いでしょう。
@param name 文字列かSymbol で指定するメ......。
@param args 呼び出すメソッドに渡す引数です。
//emlist[][ruby]{
p -365.send(:abs) #=> 365
p "ruby".send(:sub,/./,"R") #=> "Ruby"
class Foo
def foo() "foo" end
def bar() "bar" end
def baz() "baz" end
end
# 任意のキーとメソッド(の名前)の関係をハッシュ......ーバは任意(Foo クラスのインスタンスである必要もない)
p Foo.new.send(methods[1]) # => "foo"
p Foo.new.send(methods[2]) # => "bar"
p Foo.new.send(methods[3]) # => "baz"
//}
@see Object#public_send, BasicObject#__send__, Object#method, Kernel.#eval, Proc, Method...