by shigemk2

当面は技術的なことしか書かない

メソッド一覧と判定

method/attributeがObjectに存在するかどうか確認するには - なんとなく日記
Rubyでメソッド一覧を確認するmethodsメソッドが便利 - タブレット上のcron

class Hoge
  def fuga
    print 'fuga'
  end

  def bar
    print 'bar'
  end
end

hoge = Hoge.new
puts hoge.methods # なんかすごい一覧が出てくる
puts hoge.respond_to?("hoge") # false
puts hoge.respond_to?("fuga") # true
inspect
tap
clone
public_methods
__send__
instance_variable_defined?
equal?
freeze
extend
send
methods
fuga
hash
dup
object_id
instance_variables
eql?
instance_eval
id
singleton_methods
bar
taint
frozen?
instance_variable_get
to_enum
instance_of?
display
to_a
type
instance_exec
protected_methods
==
===
instance_variable_set
enum_for
kind_of?
respond_to?
method
to_s
class
__id__
tainted?
=~
private_methods
untaint
nil?
is_a?