Class: Pacer::Filter::UniqueSectionFilter::UniqueSectionPipe

Inherits:
Pipes::RubyPipe
  • Object
show all
Defined in:
lib/pacer/filter/uniq_section.rb

Instance Attribute Summary collapse

Attributes inherited from Pipes::RubyPipe

#starts

Instance Method Summary collapse

Methods inherited from Pipes::RubyPipe

#enablePath, #setStarts

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

#routeObject (readonly)

Returns the value of attribute route.



24
25
26
# File 'lib/pacer/filter/uniq_section.rb', line 24

def route
  @route
end

#sectionObject (readonly)

Returns the value of attribute section.



24
25
26
# File 'lib/pacer/filter/uniq_section.rb', line 24

def section
  @section
end

#seenObject (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_elementObject



45
46
47
# File 'lib/pacer/filter/uniq_section.rb', line 45

def after_element
  seen.clear
end

#processNextStartObject



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

#resetObject



49
50
51
# File 'lib/pacer/filter/uniq_section.rb', line 49

def reset
  seen.clear
end