Sha256: f393b1c18ac68b9ef306cfd241fe0fca5b611376955f829813e5b8c43540503b

Contents?: true

Size: 1.32 KB

Versions: 26

Compression:

Stored size: 1.32 KB

Contents

module Pacer
  module Pipes
    class SimpleVisitorPipe < Pacer::Pipes::RubyPipe
      attr_reader :visitor, :in_section, :wrapper, :graph

      attr_accessor :use_on_raw_element, :use_on_element, :use_after_element, :use_visitor_reset

      def initialize(wrapper, graph)
        super()
        @in_section = false
        @wrapper = wrapper
        @graph = graph
      end

      def visitor=(visitor)
        @visitor = visitor
        @use_on_raw_element  = visitor.respond_to? :on_raw_element
        @use_on_element      = visitor.respond_to? :on_element
        @use_after_element   = visitor.respond_to? :after_element
        @use_visitor_reset   = visitor.respond_to? :visitor_reset
      end

      def processNextStart
        visitor.after_element if use_after_element and in_section
        current = starts.next
        @in_section = true unless in_section
        visitor.on_raw_element current if use_on_raw_element
        if use_on_element
          wrapped = wrapper.new graph, current
          visitor.on_element(wrapped)
        end
        return current
      rescue EmptyPipe, java.util.NoSuchElementException
        @in_section = false
        raise EmptyPipe.instance
      end

      def reset
        visitor.visitor_reset if use_visitor_reset
        @in_section = false
        super
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
pacer-2.0.24-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.22-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.20-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.19-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.18-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.17-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.16-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.15-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.14-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.13-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.12-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.10-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.10.pre-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.8-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.6-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.4.pre-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-2.0.0.pre-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-1.6.0-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-1.5.4-java lib/pacer/pipe/simple_visitor_pipe.rb
pacer-1.5.3-java lib/pacer/pipe/simple_visitor_pipe.rb