class Necromancer::NumericConverters::StringToNumericConverter
An object that converts a String to a Numeric
Public Instance Methods
call(value, options = {})
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 68 def call(value, options = {}) strict = options.fetch(:strict, config.strict) case value when INTEGER_MATCHER StringToIntegerConverter.new(:string, :integer).call(value, options) when FLOAT_MATCHER StringToFloatConverter.new(:string, :float).call(value, options) else strict ? fail_conversion_type(value) : value end end