Class: Resync::XML::HashCodesNode

Inherits:
XML::MappingExtensions::NodeBase
  • Object
show all
Defined in:
lib/resync/xml.rb

Overview

Maps the whitespace-separated list of hash codes in a <rs:ln> or <rs:md> tag to a hash of digest values keyed by hash algorithm. (See Descriptor#hashes.)

Instance Method Summary collapse

Instance Method Details

#to_value(xml_text) ⇒ Object



69
70
71
72
73
# File 'lib/resync/xml.rb', line 69

def to_value(xml_text)
  return {} unless xml_text
  return xml_text if xml_text.is_a?(Hash)
  xml_text.split(/[[:space:]]+/).map { |hash| hash.split(':') }.to_h
end

#to_xml_text(value) ⇒ Object



75
76
77
# File 'lib/resync/xml.rb', line 75

def to_xml_text(value)
  value.map { |k, v| "#{k}:#{v}" }.join(' ') if value && !value.empty?
end