Class: Pacer::Filter::UniqueSectionFilter::UniqueSectionPipe
- Inherits:
-
Pipes::RubyPipe
- Object
- AbstractPipe
- Pipes::RubyPipe
- Pacer::Filter::UniqueSectionFilter::UniqueSectionPipe
- Defined in:
- lib/pacer/filter/uniq_section.rb
Instance Attribute Summary collapse
-
#route ⇒ Object
readonly
Returns the value of attribute route.
-
#section ⇒ Object
readonly
Returns the value of attribute section.
-
#seen ⇒ Object
readonly
Returns the value of attribute seen.
Attributes inherited from Pipes::RubyPipe
Instance Method Summary collapse
- #after_element ⇒ Object
-
#initialize(route, section) ⇒ UniqueSectionPipe
constructor
A new instance of UniqueSectionPipe.
- #processNextStart ⇒ Object
- #reset ⇒ Object
Methods inherited from Pipes::RubyPipe
Constructor Details
#initialize(route, section) ⇒ UniqueSectionPipe
Returns a new instance of UniqueSectionPipe.
27 28 29 30 31 32 33 |
# File 'lib/pacer/filter/uniq_section.rb', line 27 def initialize(route, section) super() @seen = Set[] @section = section @route = route section.visitor = self if section end |
Instance Attribute Details
#route ⇒ Object (readonly)
Returns the value of attribute route.
24 25 26 |
# File 'lib/pacer/filter/uniq_section.rb', line 24 def route @route end |
#section ⇒ Object (readonly)
Returns the value of attribute section.
24 25 26 |
# File 'lib/pacer/filter/uniq_section.rb', line 24 def section @section end |
#seen ⇒ Object (readonly)
Returns the value of attribute seen.
24 25 26 |
# File 'lib/pacer/filter/uniq_section.rb', line 24 def seen @seen end |
Instance Method Details
#after_element ⇒ Object
45 46 47 |
# File 'lib/pacer/filter/uniq_section.rb', line 45 def after_element seen.clear end |
#processNextStart ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/pacer/filter/uniq_section.rb', line 35 def processNextStart while true element = starts.next unless seen.include? element seen << element return element end end end |
#reset ⇒ Object
49 50 51 |
# File 'lib/pacer/filter/uniq_section.rb', line 49 def reset seen.clear end |