Class: Necromancer::ArrayConverters::ArrayToIntegerArrayConverter

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, 2, 3]


98
99
100
101
102
# File 'lib/necromancer/converters/array.rb', line 98

def call(array, strict: config.strict)
  int_converter = NumericConverters::StringToIntegerConverter.new(:string,
                                                                  :integer)
  array.map { |val| int_converter.(val, strict: strict) }
end