Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/unisec/utils.rb
Instance Method Summary collapse
-
#to_bool ⇒ TrueClass|FalseClass
Convert a string to a boolean.
Instance Method Details
#to_bool ⇒ TrueClass|FalseClass
Convert a string to a boolean
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/unisec/utils.rb', line 28 def to_bool case to_s.chomp.downcase when 'true', 'yes', 'y', '1' true when 'false', 'no', 'n', '0' false else raise ArgumentError, "invalid value for Boolean: #{str.inspect}" end end |