Module: ToBoolean::InstanceMethods

Defined in:
lib/datatablesnet/types.rb

Instance Method Summary collapse

Instance Method Details

#to_bObject

Raises:

  • (ArgumentError)


23
24
25
26
27
28
# File 'lib/datatablesnet/types.rb', line 23

def to_b
  string = self
  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