Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/safebool.rb

Instance Method Summary collapse

Instance Method Details

#to_bObject Also known as: to_bool



85
86
87
88
89
90
91
92
93
94
# File 'lib/safebool.rb', line 85

def to_b
  case self.downcase.strip
  when 'true', 'yes', 'on', 't', 'y', '1'
    return true
  ## when 'nil', 'null'   # todo/discuss - add why? why not?
  ##  return nil
  else
    return false
  end
end