Class: Object

Inherits:
BasicObject
Defined in:
lib/origen/core_ext/object.rb

Instance Method Summary collapse

Instance Method Details

#try(*methods) ⇒ Object

Tries the given methods and returns the first one to return a value, ultimately returns nil if no value is found.


4
5
6
7
8
9
10
11
12
# File 'lib/origen/core_ext/object.rb', line 4

def try(*methods)
  methods.each do |method|
    if self.respond_to?(method)
      val = send(method)
      return val if val
    end
  end
  nil
end