Class: Pacer::Filter::LimitSectionFilter::LimitSectionPipe

Inherits:
Pipes::RubyPipe
  • Object
show all
Defined in:
lib/pacer/filter/limit_section_filter.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, max) ⇒ LimitSectionPipe

Returns a new instance of LimitSectionPipe.



30
31
32
33
34
35
36
37
# File 'lib/pacer/filter/limit_section_filter.rb', line 30

def initialize(route, section, max)
  super()
  @hits = 0
  @max = max
  @section = section
  @route = route
  section.visitor = self if section
end

Instance Attribute Details

#hitsObject

Returns the value of attribute hits.



27
28
29
# File 'lib/pacer/filter/limit_section_filter.rb', line 27

def hits
  @hits
end

#maxObject (readonly)

Returns the value of attribute max.



26
27
28
# File 'lib/pacer/filter/limit_section_filter.rb', line 26

def max
  @max
end

#routeObject (readonly)

Returns the value of attribute route.



26
27
28
# File 'lib/pacer/filter/limit_section_filter.rb', line 26

def route
  @route
end

#sectionObject (readonly)

Returns the value of attribute section.



26
27
28
# File 'lib/pacer/filter/limit_section_filter.rb', line 26

def section
  @section
end

Instance Method Details

#after_elementObject



47
48
49
# File 'lib/pacer/filter/limit_section_filter.rb', line 47

def after_element
  self.hits = 0
end

#processNextStartObject



39
40
41
42
43
44
45
# File 'lib/pacer/filter/limit_section_filter.rb', line 39

def processNextStart
  while hits == max
    starts.next
  end
  self.hits += 1
  starts.next
end

#resetObject



51
52
53
# File 'lib/pacer/filter/limit_section_filter.rb', line 51

def reset
  self.hits = 0
end