Class: ArcFurnace::Filter
- Defined in:
- lib/arc-furnace/filter.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Node
#error_handler, #node_id, #params
Instance Method Summary collapse
- #advance ⇒ Object
- #empty? ⇒ Boolean
-
#filter(row) ⇒ Object
Given a row from the source, tell if it should be passed down to the next node downstream from this node.
-
#initialize(source:) ⇒ Filter
constructor
A new instance of Filter.
- #value ⇒ Object
Methods inherited from Source
#close, #finalize, #prepare, #row
Constructor Details
#initialize(source:) ⇒ Filter
Returns a new instance of Filter.
11 12 13 14 |
# File 'lib/arc-furnace/filter.rb', line 11 def initialize(source:) @source = source @value = nil end |
Instance Method Details
#advance ⇒ Object
34 35 36 37 38 39 |
# File 'lib/arc-furnace/filter.rb', line 34 def advance loop do @value = source.row break if value.nil? || filter(value) end end |
#empty? ⇒ Boolean
30 31 32 |
# File 'lib/arc-furnace/filter.rb', line 30 def empty? @value.nil? && source.empty? end |
#filter(row) ⇒ Object
Given a row from the source, tell if it should be passed down to the next node downstream from this node.
This method must return a boolean
26 27 28 |
# File 'lib/arc-furnace/filter.rb', line 26 def filter(row) raise "Unimplemented" end |
#value ⇒ Object
16 17 18 19 20 21 |
# File 'lib/arc-furnace/filter.rb', line 16 def value if @value.nil? && !empty? advance end @value end |