Class: Pacer::Pipes::VisitorPipe
- Defined in:
- lib/pacer/pipe/visitor_pipe.rb
Instance Attribute Summary collapse
-
#in_section ⇒ Object
readonly
Returns the value of attribute in_section.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#use_after_element ⇒ Object
Returns the value of attribute use_after_element.
-
#use_hasNext ⇒ Object
Returns the value of attribute use_hasNext.
-
#use_next ⇒ Object
Returns the value of attribute use_next.
-
#use_on_element ⇒ Object
Returns the value of attribute use_on_element.
-
#use_replace_element ⇒ Object
Returns the value of attribute use_replace_element.
-
#use_reset ⇒ Object
Returns the value of attribute use_reset.
-
#visitor ⇒ Object
Returns the value of attribute visitor.
Attributes inherited from RubyPipe
Instance Method Summary collapse
-
#initialize(visitor = nil) ⇒ VisitorPipe
constructor
A new instance of VisitorPipe.
- #processNextStart ⇒ Object
- #reset ⇒ Object
Methods inherited from RubyPipe
Constructor Details
#initialize(visitor = nil) ⇒ VisitorPipe
Returns a new instance of VisitorPipe.
9 10 11 12 13 14 |
# File 'lib/pacer/pipe/visitor_pipe.rb', line 9 def initialize(visitor = nil) super() self.visitor = visitor if visitor @queue = [] @in_section = false end |
Instance Attribute Details
#in_section ⇒ Object (readonly)
Returns the value of attribute in_section.
4 5 6 |
# File 'lib/pacer/pipe/visitor_pipe.rb', line 4 def in_section @in_section end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
4 5 6 |
# File 'lib/pacer/pipe/visitor_pipe.rb', line 4 def queue @queue end |
#use_after_element ⇒ Object
Returns the value of attribute use_after_element.
6 7 8 |
# File 'lib/pacer/pipe/visitor_pipe.rb', line 6 def use_after_element @use_after_element end |
#use_hasNext ⇒ Object
Returns the value of attribute use_hasNext.
6 7 8 |
# File 'lib/pacer/pipe/visitor_pipe.rb', line 6 def use_hasNext @use_hasNext end |
#use_next ⇒ Object
Returns the value of attribute use_next.
6 7 8 |
# File 'lib/pacer/pipe/visitor_pipe.rb', line 6 def use_next @use_next end |
#use_on_element ⇒ Object
Returns the value of attribute use_on_element.
6 7 8 |
# File 'lib/pacer/pipe/visitor_pipe.rb', line 6 def use_on_element @use_on_element end |
#use_replace_element ⇒ Object
Returns the value of attribute use_replace_element.
6 7 8 |
# File 'lib/pacer/pipe/visitor_pipe.rb', line 6 def use_replace_element @use_replace_element end |
#use_reset ⇒ Object
Returns the value of attribute use_reset.
6 7 8 |
# File 'lib/pacer/pipe/visitor_pipe.rb', line 6 def use_reset @use_reset end |
#visitor ⇒ Object
Returns the value of attribute visitor.
4 5 6 |
# File 'lib/pacer/pipe/visitor_pipe.rb', line 4 def visitor @visitor end |
Instance Method Details
#processNextStart ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pacer/pipe/visitor_pipe.rb', line 30 def processNextStart while true visitor.after_element if use_after_element and in_section if use_next and (not use_hasNext or visitor.hasNext) return visitor.next elsif queue.any? return queue.shift else current = starts.next @in_section = true unless in_section visitor.on_element(current) if use_on_element if use_replace_element visitor.replace_element(current) do |e| queue << e end else return current end end end rescue EmptyPipe, java.util.NoSuchElementException @in_section = false raise EmptyPipe.instance end |
#reset ⇒ Object
55 56 57 58 59 60 |
# File 'lib/pacer/pipe/visitor_pipe.rb', line 55 def reset visitor.reset if use_reset @in_section = false @queue = [] super end |