Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/to-bool.rb

Instance Method Summary collapse

Instance Method Details

#to_boolObject



2
3
4
5
6
7
8
9
# File 'lib/to-bool.rb', line 2

def to_bool
  if self =~ /^(true|false)$/
    return true if $1 == 'true'
    return false if $1 == 'false'
  else
    raise ArgumentError.new("invalid value for `to_bool': '#{self}'")
  end
end