Class: Arclight::HashAbsoluteXpath
- Inherits:
-
Object
- Object
- Arclight::HashAbsoluteXpath
- Defined in:
- lib/arclight/hash_absolute_xpath.rb
Overview
Take a Nokogiri node and get its absolute path (inserting our own indexes for component levels) and hash that outout. This is intended as a potential strategy for handling missing IDs in EADs.
Constant Summary collapse
- COMPONENT_NODE_NAME_REGEX =
/^c\d{,2}$/
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #absolute_xpath ⇒ Object
-
#initialize(node) ⇒ HashAbsoluteXpath
constructor
A new instance of HashAbsoluteXpath.
- #to_hexdigest ⇒ Object
Constructor Details
#initialize(node) ⇒ HashAbsoluteXpath
Returns a new instance of HashAbsoluteXpath.
23 24 25 |
# File 'lib/arclight/hash_absolute_xpath.rb', line 23 def initialize(node) @node = node end |
Class Attribute Details
.hash_algorithm ⇒ Object
13 14 15 16 17 |
# File 'lib/arclight/hash_absolute_xpath.rb', line 13 def hash_algorithm return Digest::SHA1 unless defined? @hash_algorithm @hash_algorithm end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
21 22 23 |
# File 'lib/arclight/hash_absolute_xpath.rb', line 21 def node @node end |
Instance Method Details
#absolute_xpath ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/arclight/hash_absolute_xpath.rb', line 31 def absolute_xpath ancestor_tree = node.ancestors.map do |ancestor| ancestor_name_and_index(ancestor) end "#{[ancestor_tree.reverse, node.name].flatten.join('/')}#{current_index}" end |
#to_hexdigest ⇒ Object
27 28 29 |
# File 'lib/arclight/hash_absolute_xpath.rb', line 27 def to_hexdigest self.class.hash_algorithm.hexdigest(absolute_xpath).prepend('al_') end |