Class: Stages::Unique
Instance Attribute Summary
Attributes inherited from Stage
Instance Method Summary collapse
-
#initialize(options = { }) ⇒ Unique
constructor
A new instance of Unique.
- #process ⇒ Object
Methods inherited from Stage
#die, #done?, #drop_leftmost!, #each, #end?, #handle_value, #initialize_loop, #input, #length, #output, #reset, #root_source, #run, #source_empty?, #to_enum, #|
Constructor Details
#initialize(options = { }) ⇒ Unique
Returns a new instance of Unique.
5 6 7 8 |
# File 'lib/stages/unique.rb', line 5 def initialize( = { }) @prefetch = [:prefetch] super() end |
Instance Method Details
#process ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/stages/unique.rb', line 10 def process set = Set.new while !source_empty? i = input added = set.add? i handle_value i if added && !@prefetch end set.each{ |x| handle_value x} if @prefetch set = nil end |