Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/ext/to_bool.rb

Instance Method Summary collapse

Instance Method Details

#to_boolObject



13
14
15
16
17
18
# File 'lib/ext/to_bool.rb', line 13

def to_bool
  return true if self == "\x01" || self == "1"
  return false if self == "\x00" || self == "0"

  raise "String '#{self}' can't be converted to Boolean."
end