Class: String

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

Instance Method Summary collapse

Instance Method Details

#to_boolObject

Convert string to bool



10
11
12
13
14
# File 'lib/core_ext/string.rb', line 10

def to_bool
  return true   if self == true   || self =~ (/(true|t|yes|y|1)$/i)
  return false  if self == false  || self.empty? || self =~ (/(false|f|no|n|0)$/i)
  return false
end