Class: Necromancer::ArrayConverters::ArrayToFloatArrayConverter

Inherits:
Converter
  • Object
show all
Defined in:
lib/necromancer/converters/array.rb

Instance Attribute Summary

Attributes inherited from Converter

#config, #convert, #source, #target

Instance Method Summary collapse

Methods inherited from Converter

create, #initialize, #raise_conversion_type

Constructor Details

This class inherits a constructor from Necromancer::Converter

Instance Method Details

#call(array, strict: config.strict) ⇒ Object

Examples:

converter.call(["1", "2", "3"]) # => [1.0, 2.0, 3.0]


110
111
112
113
114
# File 'lib/necromancer/converters/array.rb', line 110

def call(array, strict: config.strict)
  float_converter = NumericConverters::StringToFloatConverter.new(:string,
                                                                  :float)
  array.map { |val| float_converter.(val, strict: strict) }
end