Class: Necromancer::NumericConverters::StringToNumericConverter
- Inherits:
-
Converter
- Object
- Converter
- Necromancer::NumericConverters::StringToNumericConverter
- Defined in:
- lib/necromancer/converters/numeric.rb
Overview
An object that converts a String to a Numeric
Instance Attribute Summary
Attributes inherited from Converter
Instance Method Summary collapse
-
#call(value, options = {}) ⇒ Object
Convert string to numeric value.
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 string to numeric value
69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/necromancer/converters/numeric.rb', line 69 def call(value, = {}) strict = .fetch(:strict, config.strict) case value when INTEGER_MATCHER StringToIntegerConverter.new(:string, :integer).call(value, ) when FLOAT_MATCHER StringToFloatConverter.new(:string, :float).call(value, ) else strict ? fail_conversion_type(value) : value end end |