Class: Itiel::Transform::SelectColumn
- Inherits:
-
Object
- Object
- Itiel::Transform::SelectColumn
- Includes:
- Nameable, ChainedStep
- Defined in:
- lib/itiel/transform/select_column.rb
Overview
Instance Attribute Summary collapse
-
#mappings ⇒ Object
Returns the value of attribute mappings.
Attributes included from Nameable
Attributes included from ChainedStep
Instance Method Summary collapse
-
#initialize(*args) ⇒ SelectColumn
constructor
A new instance of SelectColumn.
- #input=(stream) ⇒ Object
- #transform!(input_stream) ⇒ Object
Constructor Details
#initialize(*args) ⇒ SelectColumn
Returns a new instance of SelectColumn.
23 24 25 |
# File 'lib/itiel/transform/select_column.rb', line 23 def initialize(*args) self.mappings = args end |
Instance Attribute Details
#mappings ⇒ Object
Returns the value of attribute mappings.
17 18 19 |
# File 'lib/itiel/transform/select_column.rb', line 17 def mappings @mappings end |
Instance Method Details
#input=(stream) ⇒ Object
19 20 21 |
# File 'lib/itiel/transform/select_column.rb', line 19 def input=(stream) next_step.input = transform!(stream) end |
#transform!(input_stream) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/itiel/transform/select_column.rb', line 27 def transform!(input_stream) selected_output = [] input_stream.each do |object| selected_output << object.select {|key, value| self.mappings.include? key } end selected_output end |