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
#config, #convert, #source, #target
Instance Method Summary collapse
-
#call(value, strict: config.strict) ⇒ Object
Convert string to numeric value.
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 string to numeric value
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/necromancer/converters/numeric.rb', line 67 def call(value, strict: config.strict) case value when INTEGER_MATCHER StringToIntegerConverter.new(:string, :integer).(value, strict: strict) when FLOAT_MATCHER StringToFloatConverter.new(:string, :float).(value, strict: strict) else strict ? raise_conversion_type(value) : value end end |