Class: Necromancer::ArrayConverters::ArrayToBooleanArrayConverter

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

Overview

An object that converts an array to an array with boolean values

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(value, strict: config.strict) ⇒ Object

Examples:

converter.call(["t", "f", "yes", "no"]) # => [true, false, true, false]

Parameters:

  • value (Array)

    the array value to boolean



144
145
146
147
148
# File 'lib/necromancer/converters/array.rb', line 144

def call(value, strict: config.strict)
  bool_converter = BooleanConverters::StringToBooleanConverter.new(:string,
                                                                   :boolean)
  value.map { |val| bool_converter.(val, strict: strict) }
end