Class: Pipetree::Collect

Inherits:
Pipetree
  • Object
show all
Defined in:
lib/pipetree.rb

Overview

Collect applies a pipeline to each element of input.

Direct Known Subclasses

Hash

Defined Under Namespace

Classes: Hash

Constant Summary

Constants inherited from Pipetree

Insert, Stop, VERSION

Instance Method Summary collapse

Methods included from Macros

#insert!

Methods included from Inspect

#inspect, #inspect_func, #inspect_line, #inspect_object, #inspect_proc, #inspect_row, #inspect_rows

Instance Method Details

#call(input, options) ⇒ Object

when stop, the element is skipped. (should that be Skip then?)



36
37
38
39
40
41
42
43
# File 'lib/pipetree.rb', line 36

def call(input, options)
  arr = []
  input.each_with_index do |item_fragment, i|
    result = super(item_fragment, options.merge(index: i)) # DISCUSS: NO :fragment set.
    Stop == result ? next : arr << result
  end
  arr
end