Class: Ronin::Core::Params::Types::Boolean
- Defined in:
- lib/ronin/core/params/types/boolean.rb
Overview
Represents a true/false param.
Instance Method Summary collapse
-
#coerce(value) ⇒ true, ...
private
Coerces a value into a boolean value.
Instance Method Details
#coerce(value) ⇒ true, ...
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Coerces a value into a boolean value.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ronin/core/params/types/boolean.rb', line 44 def coerce(value) case value when nil then false when true, false then value when ::String case value when /\A(?:true|yes|y|on)\z/i then true when /\A(?:false|no|n|off)\z/i then false else raise(ValidationError,"value must be either 'true', 'false', 'yes', 'no', 'y', 'n', 'on', or 'off' (#{value.inspect})") end else raise(ValidationError,"value must be either true, false, or a String (#{value.inspect})") end end |