Class: Burner::Library::Collection::Concatenate
- Defined in:
- lib/burner/library/collection/concatenate.rb
Overview
Instance Attribute Summary collapse
-
#from_registers ⇒ Object
readonly
Returns the value of attribute from_registers.
-
#to_register ⇒ Object
readonly
Returns the value of attribute to_register.
Attributes inherited from Job
Instance Method Summary collapse
-
#initialize(from_registers: [], name: '', to_register: DEFAULT_REGISTER) ⇒ Concatenate
constructor
A new instance of Concatenate.
- #perform(output, payload) ⇒ Object
Methods included from Util::Arrayable
Constructor Details
#initialize(from_registers: [], name: '', to_register: DEFAULT_REGISTER) ⇒ Concatenate
Returns a new instance of Concatenate.
21 22 23 24 25 26 27 28 |
# File 'lib/burner/library/collection/concatenate.rb', line 21 def initialize(from_registers: [], name: '', to_register: DEFAULT_REGISTER) super(name: name) @from_registers = Array(from_registers) @to_register = to_register.to_s freeze end |
Instance Attribute Details
#from_registers ⇒ Object (readonly)
Returns the value of attribute from_registers.
19 20 21 |
# File 'lib/burner/library/collection/concatenate.rb', line 19 def from_registers @from_registers end |
#to_register ⇒ Object (readonly)
Returns the value of attribute to_register.
19 20 21 |
# File 'lib/burner/library/collection/concatenate.rb', line 19 def to_register @to_register end |
Instance Method Details
#perform(output, payload) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/burner/library/collection/concatenate.rb', line 30 def perform(output, payload) output.detail("Concatenating registers: '#{from_registers}' to: '#{to_register}'") payload[to_register] = from_registers.each_with_object([]) do |from_register, memo| from_register_value = array(payload[from_register]) memo.concat(from_register_value) end end |