Class: Object

Inherits:
BasicObject
Defined in:
lib/wfjrd/wfjrd.rb

Instance Method Summary collapse

Instance Method Details

#method?(sym) ⇒ Boolean

Tests whether the method exists. Unlike the std method, however, does not throw a NameError if it doesn’t. Just returns false

Returns:

  • (Boolean)


58
59
60
# File 'lib/wfjrd/wfjrd.rb', line 58

def method? sym
  method sym rescue false
end

#one_of_type?(*args) ⇒ Boolean

Tests to see if the Object is one of several possible types like is_a? but accepting multiple arguments

Returns:

  • (Boolean)


64
65
66
# File 'lib/wfjrd/wfjrd.rb', line 64

def one_of_type? *args
  args.any? {|x| is_a? x}
end