Class: Wukong::Processor::Uniq
- Inherits:
-
Accumulator
- Object
- Hanuman::Stage
- Wukong::Processor
- Accumulator
- Wukong::Processor::Uniq
- Defined in:
- lib/wukong/widget/reducers/uniq.rb
Overview
A processor which emits only unique records from its input.
It's intended to work just like uniq
.
Constant Summary
Constants inherited from Wukong::Processor
Instance Attribute Summary collapse
-
#size ⇒ Object
The total size of the input recors.
Attributes inherited from Accumulator
Attributes included from Hanuman::StageInstanceMethods
Instance Method Summary collapse
-
#accumulate(record) ⇒ Object
Accumulate a
record
by incrmenting the total size. -
#finalize {|size| ... } ⇒ Object
Yields the total size.
-
#setup ⇒ Object
Initializes the count to 0.
Methods inherited from Accumulator
Methods inherited from Wukong::Processor
configure, description, #perform_action, #process, #receive_action, #stop
Methods included from Logging
Methods inherited from Hanuman::Stage
Methods included from Hanuman::StageClassMethods
#builder, #label, #register, #set_builder
Methods included from Hanuman::StageInstanceMethods
#add_link, #linkable_name, #root
Instance Attribute Details
#size ⇒ Object
The total size of the input recors.
60 61 62 |
# File 'lib/wukong/widget/reducers/uniq.rb', line 60 def size @size end |
Instance Method Details
#accumulate(record) ⇒ Object
Accumulate a record
by incrmenting the total size.
71 72 73 |
# File 'lib/wukong/widget/reducers/uniq.rb', line 71 def accumulate record self.size += 1 end |
#finalize {|size| ... } ⇒ Object
Yields the total size.
79 80 81 82 83 84 85 |
# File 'lib/wukong/widget/reducers/uniq.rb', line 79 def finalize if count yield [key, self.size] else yield key end end |
#setup ⇒ Object
Initializes the count to 0.
63 64 65 66 |
# File 'lib/wukong/widget/reducers/uniq.rb', line 63 def setup super() @size = 0 end |