Class: SvgConform::NodeIndexBuilder
- Inherits:
-
Object
- Object
- SvgConform::NodeIndexBuilder
- Defined in:
- lib/svg_conform/node_index_builder.rb
Overview
Builds an index of node positions in single forward pass Replicates the exact logic of backward sibling traversal but computed forward
Instance Method Summary collapse
-
#get_position(node) ⇒ Object
Get position of node among its siblings with same name.
-
#initialize(document) ⇒ NodeIndexBuilder
constructor
A new instance of NodeIndexBuilder.
Constructor Details
#initialize(document) ⇒ NodeIndexBuilder
Returns a new instance of NodeIndexBuilder.
7 8 9 10 |
# File 'lib/svg_conform/node_index_builder.rb', line 7 def initialize(document) @node_positions = {} build_index(document.root) if document.root end |
Instance Method Details
#get_position(node) ⇒ Object
Get position of node among its siblings with same name
13 14 15 |
# File 'lib/svg_conform/node_index_builder.rb', line 13 def get_position(node) @node_positions[node] end |