Class: String

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, downcased, the receiver is “1” or “true”, false if “0” or “false”, or nil otherwise.



31
32
33
34
35
36
37
38
# File 'lib/certainty.rb', line 31

def to_bool
  {
    '1'     => true,
    'true'  => true,
    '0'     => false,
    'false' => false
  }[downcase]
end