Class: SvgConform::FastDocumentAnalyzer
- Inherits:
-
Object
- Object
- SvgConform::FastDocumentAnalyzer
- Defined in:
- lib/svg_conform/fast_document_analyzer.rb
Overview
Fast document analyzer that pre-computes node relationships and IDs in a single pass to avoid repeated expensive traversals
IMPORTANT: Stores paths indexed by the path itself (not object_id) since node object_ids change between traversals
Instance Attribute Summary collapse
-
#path_cache ⇒ Object
readonly
Returns the value of attribute path_cache.
Instance Method Summary collapse
-
#get_node_id(node) ⇒ Object
Get cached path-based ID for a node by computing its path once.
-
#initialize(document) ⇒ FastDocumentAnalyzer
constructor
A new instance of FastDocumentAnalyzer.
Constructor Details
#initialize(document) ⇒ FastDocumentAnalyzer
12 13 14 15 16 17 |
# File 'lib/svg_conform/fast_document_analyzer.rb', line 12 def initialize(document) @document = document @path_cache = {} analyze_document end |
Instance Attribute Details
#path_cache ⇒ Object (readonly)
Returns the value of attribute path_cache.
10 11 12 |
# File 'lib/svg_conform/fast_document_analyzer.rb', line 10 def path_cache @path_cache end |
Instance Method Details
#get_node_id(node) ⇒ Object
Get cached path-based ID for a node by computing its path once
20 21 22 23 24 25 |
# File 'lib/svg_conform/fast_document_analyzer.rb', line 20 def get_node_id(node) return nil unless node.respond_to?(:name) && node.name # Compute path for this node (fast with forward traversal counting) compute_path_forward(node) end |