Class: String

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

Instance Method Summary collapse

Instance Method Details

#to_booleanObject

Raises:

  • (ArgumentError)


2
3
4
5
6
7
# File 'lib/tfg_support/string.rb', line 2

def to_boolean
  return true if self =~ (/\A(true|t|yes|y|1)\Z/i)
  return false if self =~ (/\A(false|f|no|n|0)\Z/i)

  raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
end