Module: Necromancer::ArrayConverters

Defined in:
lib/necromancer/converters/array.rb

Overview

Container for Array converter classes

Defined Under Namespace

Classes: ArrayToBooleanArrayConverter, ArrayToFloatArrayConverter, ArrayToIntegerArrayConverter, ArrayToNumericArrayConverter, ArrayToSetConverter, ObjectToArrayConverter, StringToArrayConverter, StringToBooleanArrayConverter, StringToFloatArrayConverter, StringToIntegerArrayConverter, StringToNumericArrayConverter

Constant Summary collapse

ARRAY_MATCHER =
/^(.+?(\s*(?<sep>(,|-))\s*))+/x.freeze

Class Method Summary collapse

Class Method Details

.load(conversions) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/necromancer/converters/array.rb', line 184

def self.load(conversions)
  [
    NullConverter.new(:array, :array),

    StringToArrayConverter.new(:string, :array),
    StringToBooleanArrayConverter.new(:string, :bools),
    StringToBooleanArrayConverter.new(:string, :booleans),
    StringToIntegerArrayConverter.new(:string, :integers),
    StringToIntegerArrayConverter.new(:string, :ints),
    StringToFloatArrayConverter.new(:string, :floats),
    StringToNumericArrayConverter.new(:string, :numerics),
    StringToNumericArrayConverter.new(:string, :nums),

    ArrayToNumericArrayConverter.new(:array, :numerics),
    ArrayToNumericArrayConverter.new(:array, :nums),
    ArrayToIntegerArrayConverter.new(:array, :integers),
    ArrayToIntegerArrayConverter.new(:array, :ints),
    ArrayToFloatArrayConverter.new(:array, :floats),
    ArrayToBooleanArrayConverter.new(:array, :booleans),
    ArrayToBooleanArrayConverter.new(:array, :bools),

    ObjectToArrayConverter.new(:object, :array),
    ObjectToArrayConverter.new(:hash, :array)
  ].each do |converter|
    conversions.register converter
  end
end