Class: Types::Boolean
- Inherits:
-
Object
- Object
- Types::Boolean
- Defined in:
- lib/kweerie/types/boolean.rb
Constant Summary collapse
- TRUTHY =
[true, 1, "1", "t", "T", "true", "TRUE"].freeze
- FALSEY =
[false, 0, "0", "f", "F", "false", "FALSE"].freeze
Instance Method Summary collapse
Instance Method Details
#cast(value) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/kweerie/types/boolean.rb', line 8 def cast(value) return nil if value.nil? return value if value.is_a?(Boolean) if TRUTHY.include?(value) true elsif FALSEY.include?(value) false else raise ArgumentError, "Invalid boolean value: #{value}" end end |