Class: Pacer::Transform::CountSection::CountSectionPipe
- Inherits:
-
Pipes::RubyPipe
- Object
- AbstractPipe
- Pipes::RubyPipe
- Pacer::Transform::CountSection::CountSectionPipe
- Defined in:
- lib/pacer/transform/count_section.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#pf ⇒ Object
readonly
Returns the value of attribute pf.
-
#section ⇒ Object
readonly
Returns the value of attribute section.
-
#section_key ⇒ Object
readonly
Returns the value of attribute section_key.
-
#to_emit ⇒ Object
readonly
Returns the value of attribute to_emit.
Attributes inherited from Pipes::RubyPipe
Instance Method Summary collapse
- #after_element ⇒ Object
- #getPathToHere ⇒ Object
-
#initialize(section, pipe_function) ⇒ CountSectionPipe
constructor
A new instance of CountSectionPipe.
- #on_element(element) ⇒ Object
- #processNextStart ⇒ Object
Methods inherited from Pipes::RubyPipe
#enablePath, #reset, #setStarts
Constructor Details
#initialize(section, pipe_function) ⇒ CountSectionPipe
Returns a new instance of CountSectionPipe.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pacer/transform/count_section.rb', line 35 def initialize(section, pipe_function) super() @count = 0 @section = section if section section.visitor = self else on_element nil end @pf = pipe_function end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
33 34 35 |
# File 'lib/pacer/transform/count_section.rb', line 33 def count @count end |
#pf ⇒ Object (readonly)
Returns the value of attribute pf.
33 34 35 |
# File 'lib/pacer/transform/count_section.rb', line 33 def pf @pf end |
#section ⇒ Object (readonly)
Returns the value of attribute section.
33 34 35 |
# File 'lib/pacer/transform/count_section.rb', line 33 def section @section end |
#section_key ⇒ Object (readonly)
Returns the value of attribute section_key.
33 34 35 |
# File 'lib/pacer/transform/count_section.rb', line 33 def section_key @section_key end |
#to_emit ⇒ Object (readonly)
Returns the value of attribute to_emit.
33 34 35 |
# File 'lib/pacer/transform/count_section.rb', line 33 def to_emit @to_emit end |
Instance Method Details
#after_element ⇒ Object
73 74 75 76 |
# File 'lib/pacer/transform/count_section.rb', line 73 def after_element @to_emit = [section_key, count] @count = 0 end |
#getPathToHere ⇒ Object
65 66 67 |
# File 'lib/pacer/transform/count_section.rb', line 65 def getPathToHere section.getCurrentPath end |
#on_element(element) ⇒ Object
69 70 71 |
# File 'lib/pacer/transform/count_section.rb', line 69 def on_element(element) @section_key = pf.compute element end |
#processNextStart ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pacer/transform/count_section.rb', line 47 def processNextStart until to_emit starts.next @count += 1 end raise EmptyPipe.instance if to_emit.empty? emit = to_emit @to_emit = nil emit rescue EmptyPipe, java.util.NoSuchElementException if count == 0 raise EmptyPipe.instance else after_element to_emit end end |