Class: Necromancer::ArrayConverters::ArrayToBooleanConverter

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

#convert, #source, #target

Instance Method Summary collapse

Methods inherited from Converter

create, #fail_conversion_type, #initialize

Constructor Details

This class inherits a constructor from Necromancer::Converter

Instance Method Details

#call(value, options = {}) ⇒ Object

Examples:

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

Parameters:

  • value (Array)

    the array value to boolean



62
63
64
65
66
67
# File 'lib/necromancer/converters/array.rb', line 62

def call(value, options = {})
  boolean_converter = BooleanConverters::StringToBooleanConverter.new(:string, :boolean)
  value.reduce([]) do |acc, el|
    acc << boolean_converter.call(el, options)
  end
end