るりまサーチ

最速Rubyリファレンスマニュアル検索!
24件ヒット [1-24件を表示] (0.079秒)

別のキーワード

  1. csv instance
  2. _builtin instance_eval
  3. basicobject instance_eval
  4. prime instance
  5. syslog instance

ライブラリ

キーワード

検索結果

Object#respond_to?(name, include_all = false) -> bool (32.0)

オブジェクトがメソッド name を持つとき真を返します。

...されたメソッドで NotImplementedError が発生する場合は true を返します。

メソッドが定義されていない場合は、Object#respond_to_missing? を呼
び出してその結果を返します。

@param name Symbol または文字列で指定するメソッド名です。...
...になります。

//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,...
...ate_method
raise NotImplementedError.new
end

def finish
puts "finish"
end
end

class
ImplTemplateMethod
include Template
def template_method
"implement template_method"
end
end

class
NotImplTemplateMethod
include Template

# not implement template_method
end

puts ImplT...

Object#instance_variables -> [Symbol] (14.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...