Class: LazierData::Processor::ChildEachSlice
- Inherits:
-
Object
- Object
- LazierData::Processor::ChildEachSlice
- Defined in:
- lib/lazier_data/processor/child_each_slice.rb
Constant Summary collapse
- NOTHING =
:_lazier_data_nothing
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
readonly
Returns the value of attribute batch_size.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#downstream ⇒ Object
readonly
Returns the value of attribute downstream.
-
#input_path ⇒ Object
readonly
Returns the value of attribute input_path.
-
#upstream ⇒ Object
readonly
Returns the value of attribute upstream.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(upstream, downstream, batch_size, input_path, &block) ⇒ ChildEachSlice
constructor
A new instance of ChildEachSlice.
Constructor Details
#initialize(upstream, downstream, batch_size, input_path, &block) ⇒ ChildEachSlice
Returns a new instance of ChildEachSlice.
10 11 12 13 14 15 16 |
# File 'lib/lazier_data/processor/child_each_slice.rb', line 10 def initialize(upstream, downstream, batch_size, input_path, &block) @upstream = upstream @downstream = downstream @batch_size = batch_size @input_path = input_path @block = block end |
Instance Attribute Details
#batch_size ⇒ Object (readonly)
Returns the value of attribute batch_size.
8 9 10 |
# File 'lib/lazier_data/processor/child_each_slice.rb', line 8 def batch_size @batch_size end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
8 9 10 |
# File 'lib/lazier_data/processor/child_each_slice.rb', line 8 def block @block end |
#downstream ⇒ Object (readonly)
Returns the value of attribute downstream.
8 9 10 |
# File 'lib/lazier_data/processor/child_each_slice.rb', line 8 def downstream @downstream end |
#input_path ⇒ Object (readonly)
Returns the value of attribute input_path.
8 9 10 |
# File 'lib/lazier_data/processor/child_each_slice.rb', line 8 def input_path @input_path end |
#upstream ⇒ Object (readonly)
Returns the value of attribute upstream.
8 9 10 |
# File 'lib/lazier_data/processor/child_each_slice.rb', line 8 def upstream @upstream end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lazier_data/processor/child_each_slice.rb', line 18 def call slicer.each_slice(batch_size) do |raw_yielded| items = raw_yielded.map(&:first) yielders = raw_yielded.last[3] @block.call(items, *yielders) raw_yielded.each do |_, root_item, item_store, _| next if root_item == NOTHING downstream << [root_item, item_store] end end end |