Class: Highway::Steps::Types::Bool
- Defined in:
- lib/highway/steps/types/bool.rb
Overview
This class represents a boolean parameter type.
Instance Method Summary collapse
-
#typecheck(value) ⇒ Boolean?
Typecheck and coerce a value if possible.
Methods inherited from Any
#initialize, #typecheck_and_validate, #validate
Constructor Details
This class inherits a constructor from Highway::Steps::Types::Any
Instance Method Details
#typecheck(value) ⇒ Boolean?
Typecheck and coerce a value if possible.
This method returns a typechecked and coerced value or ‘nil` if value has invalid type and can’t be coerced.
25 26 27 28 29 30 |
# File 'lib/highway/steps/types/bool.rb', line 25 def typecheck(value) case value when ::TrueClass, 1, "1", "true", "yes" then true when ::FalseClass, 0, "0", "false", "no" then false end end |