Module: Kernel

Defined in:
lib/ptj/ext/datamapper_collection.rb

Instance Method Summary collapse

Instance Method Details

#Boolean(string) ⇒ Object

Raises:

  • (ArgumentError)


68
69
70
71
72
# File 'lib/ptj/ext/datamapper_collection.rb', line 68

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