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
Instance Method Summary collapse
-
#call(value, options = {}) ⇒ Object
Convert value to boolean type including range of strings.
Methods inherited from Converter
create, #fail_conversion_type, #initialize
Constructor Details
This class inherits a constructor from Necromancer::Converter
Instance Method Details
#call(value, options = {}) ⇒ 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 39 |
# File 'lib/necromancer/converters/boolean.rb', line 32 def call(value, = {}) strict = .fetch(:strict, config.strict) case value.to_s when TRUE_MATCHER then true when FALSE_MATCHER then false else strict ? fail_conversion_type(value) : value end end |