Class: String

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

Instance Method Summary collapse

Instance Method Details

#to_boolObject

Raises:

  • (ArgumentError)


33
34
35
36
37
38
# File 'lib/foliokit.rb', line 33

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

  raise ArgumentError, "invalid value for Boolean: \"#{self}\""
end