Class: Cosmos::WatermarkProcessor
- Defined in:
- lib/cosmos/processors/watermark_processor.rb
Instance Attribute Summary
Attributes inherited from Processor
Instance Method Summary collapse
-
#call(packet, buffer) ⇒ Object
Run watermarks on the item.
-
#initialize(item_name, value_type = :CONVERTED) ⇒ WatermarkProcessor
constructor
A new instance of WatermarkProcessor.
-
#reset ⇒ Object
Reset any state.
Methods inherited from Processor
Constructor Details
#initialize(item_name, value_type = :CONVERTED) ⇒ WatermarkProcessor
Returns a new instance of WatermarkProcessor.
19 20 21 22 23 |
# File 'lib/cosmos/processors/watermark_processor.rb', line 19 def initialize(item_name, value_type = :CONVERTED) super(value_type) @item_name = item_name.to_s.upcase reset() end |
Instance Method Details
#call(packet, buffer) ⇒ Object
Run watermarks on the item
See Processor#call
28 29 30 31 32 33 34 |
# File 'lib/cosmos/processors/watermark_processor.rb', line 28 def call(packet, buffer) value = packet.read(@item_name, @value_type, buffer) high_water = @results[:HIGH_WATER] @results[:HIGH_WATER] = value if !high_water or value > high_water low_water = @results[:LOW_WATER] @results[:LOW_WATER] = value if !low_water or value < low_water end |
#reset ⇒ Object
Reset any state
37 38 39 40 |
# File 'lib/cosmos/processors/watermark_processor.rb', line 37 def reset @results[:HIGH_WATER] = nil @results[:LOW_WATER] = nil end |