Module: RubyExtension::Object::InstanceMethods

Defined in:
lib/ruby_extension/object.rb

Overview

module ClassMethods # :nodoc: end

Instance Method Summary collapse

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)

Returns:

  • (Boolean)


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_booleanObject



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

Returns:

  • (Boolean)


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