Class: Numeric

Inherits:
Object show all
Defined in:
lib/certainty.rb

Instance Method Summary collapse

Instance Method Details

#to_boolObject Also known as: to_b

Returns true if the receiver, converted to float, is equal to 1.0, false if 0.0, or nil otherwise.



45
46
47
48
49
50
# File 'lib/certainty.rb', line 45

def to_bool
  {
    1.0 => true,
    0.0 => false
  }[to_f]
end