Module: RubyExtension::Object::InstanceMethods
- Defined in:
- lib/ruby_extension/object.rb
Overview
module ClassMethods # :nodoc: end
Instance Method Summary collapse
-
#evaluate_method(method, *args, &block) ⇒ Object
(also: #x)
def evaluate_method(method, *args, &block).
-
#false? ⇒ Boolean
looking for an explicit false (not nil).
- #to_boolean ⇒ Object
-
#true? ⇒ Boolean
looking for an explicit true.
Instance Method Details
#evaluate_method(method, *args, &block) ⇒ Object Also known as: x
def evaluate_method(method, *args, &block)
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ruby_extension/object.rb', line 22 def evaluate_method(method, *args, &block) case method when Symbol # I don't quite understand the shift (it fails) # object = args.shift # object.send(method, *args, &block) send(method, *args, &block) when String eval(method, args.first.instance_eval { binding }) when Proc, Method # fails method.call(*args, &block) else if method.respond_to?(kind) method.send(kind, *args, &block) else raise ArgumentError, "Callbacks must be a symbol denoting the method to call, a string to be evaluated, " + "a block to be invoked, or an object responding to the callback method." end end end |
#false? ⇒ Boolean
looking for an explicit false (not nil)
59 60 61 62 |
# File 'lib/ruby_extension/object.rb', line 59 def false? return [false, 'false', 0, '0', 'f'].include?( ( self.is_a?(String) ) ? self.downcase : self ) end |
#to_boolean ⇒ Object
46 47 48 49 50 |
# File 'lib/ruby_extension/object.rb', line 46 def to_boolean # return [true, 'true', 1, '1', 't'].include?( return ![nil, false, 'false', 0, '0', 'f'].include?( ( self.is_a?(String) ) ? self.downcase : self ) end |
#true? ⇒ Boolean
looking for an explicit true
53 54 55 56 |
# File 'lib/ruby_extension/object.rb', line 53 def true? return [true, 'true', 1, '1', 't'].include?( ( self.is_a?(String) ) ? self.downcase : self ) end |