Sha256: 9dd91ad579842228a61dcf626ae5e60e43c2d5727a434b29e0dda97632de02cb
Contents?: true
Size: 1.21 KB
Versions: 28
Compression:
Stored size: 1.21 KB
Contents
module Pacer module Routes module RouteOperations def limit_section(section = nil, max) chain_route filter: Pacer::Filter::LimitSectionFilter, section_max: max, section: section end end end module Filter module LimitSectionFilter # VisitsSection module provides: # section= # section_visitor include Pacer::Visitors::VisitsSection attr_accessor :section_max def attach_pipe(end_pipe) pipe = LimitSectionPipe.new(self, section_visitor, section_max) pipe.setStarts end_pipe if end_pipe pipe end class LimitSectionPipe < Pacer::Pipes::RubyPipe attr_reader :max, :section, :route attr_accessor :hits def initialize(route, section, max) super() @hits = 0 @max = max @section = section @route = route section.visitor = self if section end def processNextStart while hits == max starts.next end self.hits += 1 starts.next end def after_element self.hits = 0 end def reset self.hits = 0 end end end end end
Version data entries
28 entries across 28 versions & 1 rubygems