Class: Pacer::Transform::SortSection::CustomSortPipe
- Inherits:
-
SortBySectionPipe
- Object
- AbstractPipe
- Pipes::RubyPipe
- SortBySectionPipe
- Pacer::Transform::SortSection::CustomSortPipe
- Defined in:
- lib/pacer/transform/sort_section.rb
Instance Attribute Summary collapse
-
#sort_block ⇒ Object
readonly
Returns the value of attribute sort_block.
Attributes inherited from SortBySectionPipe
#getPathToHere, #nil_value, #pf_1, #pf_2, #route, #section, #to_emit, #to_sort
Attributes inherited from Pipes::RubyPipe
Instance Method Summary collapse
- #after_element ⇒ Object
-
#initialize(route, visitor_pipe, sort_block, graph, wrapper) ⇒ CustomSortPipe
constructor
A new instance of CustomSortPipe.
Methods inherited from SortBySectionPipe
#on_element, #processNextStart, #setStarts
Methods inherited from Pipes::RubyPipe
#enablePath, #reset, #setStarts
Constructor Details
#initialize(route, visitor_pipe, sort_block, graph, wrapper) ⇒ CustomSortPipe
Returns a new instance of CustomSortPipe.
163 164 165 166 167 168 |
# File 'lib/pacer/transform/sort_section.rb', line 163 def initialize(route, visitor_pipe, sort_block, graph, wrapper) super route, visitor_pipe, nil, nil @sort_block = sort_block @graph = graph @wrapper = wrapper end |
Instance Attribute Details
#sort_block ⇒ Object (readonly)
Returns the value of attribute sort_block.
161 162 163 |
# File 'lib/pacer/transform/sort_section.rb', line 161 def sort_block @sort_block end |
Instance Method Details
#after_element ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/pacer/transform/sort_section.rb', line 170 def after_element if to_sort.any? to_sort.map! { |e| [ @wrapper.new(@graph, e.first), e.last ] } sorted = to_sort.sort { |a, b| @sort_block.call a.first, b.first } if route.element_type == :vertex || route.element_type == :edge to_emit.concat sorted.map { |e| [ e.first.element, e.last ] } else to_emit.concat sorted end @to_sort.clear end end |