Sha256: 947c8bf44e7ed473dc63e78586438536ce895bdf6a88f092d4ced4cf72e2a80f
Contents?: true
Size: 809 Bytes
Versions: 1
Compression:
Stored size: 809 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 attr_reader :value def initialize(source:) @source = source advance 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
arc-furnace-0.1.3 | lib/arc-furnace/filter.rb |