Class: Datapipes::Tube

Inherits:
Object
  • Object
show all
Defined in:
lib/datapipes/tube.rb

Overview

Tube takes effect data which passes through pipe.

Build your own tube logic in ‘run` method.

Direct Known Subclasses

Basics::Triple

Instance Method Summary collapse

Instance Method Details

#accept?(data) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/datapipes/tube.rb', line 18

def accept?(data)
  true
end

#run_all(data) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/datapipes/tube.rb', line 6

def run_all(data)
  accumulated ||= [self]

  accumulated.reduce(data) do |d, tube|
    if tube.accept? d
      tube.run(d)
    else
      d
    end
  end
end