Sha256: ce6b7878c2f87c952f439bea59e2567a14be153c1b715a6905f71ff7f5101c7c
Contents?: true
Size: 885 Bytes
Versions: 38
Compression:
Stored size: 885 Bytes
Contents
require 'arc-furnace/source' # Filters limit rows to downstream nodes. They act just like Enumerable#filter: # when the #filter method returns true, the row is passed downstream. when # it returns false, the row is skipped. module ArcFurnace class Filter < Source private_attr_reader :source def initialize(source:) @source = source @value = nil end def value if @value.nil? && !empty? advance end @value end # 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 def filter(row) raise "Unimplemented" end def empty? @value.nil? && source.empty? end def advance loop do @value = source.row break if value.nil? || filter(value) end end end end
Version data entries
38 entries across 38 versions & 1 rubygems