Class: Necromancer::BooleanConverters::StringToBooleanConverter
- Inherits:
-
Converter
- Object
- Converter
- Necromancer::BooleanConverters::StringToBooleanConverter
- Defined in:
- lib/necromancer/converters/boolean.rb
Overview
An object that converts a String to a Boolean
Instance Attribute Summary
Attributes inherited from Converter
#config, #convert, #source, #target
Instance Method Summary collapse
-
#call(value, strict: config.strict) ⇒ Object
Convert value to boolean type including range of strings.
Methods inherited from Converter
create, #initialize, #raise_conversion_type
Constructor Details
This class inherits a constructor from Necromancer::Converter
Instance Method Details
#call(value, strict: config.strict) ⇒ Object
Convert value to boolean type including range of strings
other values coerced to false are:
0, f, F, FALSE, false, False, n, N, NO, no, No, off, OFF
32 33 34 35 36 37 38 |
# File 'lib/necromancer/converters/boolean.rb', line 32 def call(value, strict: config.strict) case value.to_s when TRUE_MATCHER then true when FALSE_MATCHER then false else strict ? raise_conversion_type(value) : value end end |