class Necromancer::NumericConverters::StringToNumericConverter
An object that converts a String to a Numeric
Public Instance Methods
call(value, strict: config.strict)
click to toggle source
Convert string to numeric value
@example
converter.call("1.0") # => 1.0
@example
converter.call("1") # => 1
@api public
# 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