Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/l5m-tools/string.rb

Instance Method Summary collapse

Instance Method Details

#to_booleanObject

Raises:

  • (ArgumentError)


2
3
4
5
6
# File 'lib/l5m-tools/string.rb', line 2

def to_boolean
    return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
    return false if self == false || self.nil? || self =~ (/(false|f|no|n|0)$/i)
    raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
end