Class: AIXM::PayloadHash

Inherits:
Object show all
Defined in:
lib/aixm/payload_hash.rb

Overview

Calculate OFMX-compliant payload hashes.

Examples:

with XML fragment string

xml = '<xml><a></a></xml>'
AIXM::PayloadHash.new(xml).to_uuid

with Nokogiri fragment

document = File.open("file.xml") { Nokogiri::XML(_1) }
AIXM::PayloadHash.new(document).to_uuid

See Also:

Defined Under Namespace

Classes: Mid

Constant Summary collapse

IGNORED_ATTRIBUTES =
%w(mid source).freeze

Instance Method Summary collapse

Constructor Details

#initialize(fragment) ⇒ PayloadHash

Returns a new instance of PayloadHash.

Parameters:

  • fragment (Nokogiri::XML::DocumentFragment, Nokogiri::XML::Element, String)

    XML fragment


20
21
22
23
24
25
26
# File 'lib/aixm/payload_hash.rb', line 20

def initialize(fragment)
  @fragment = case fragment
    when Nokogiri::XML::DocumentFragment then fragment
    when Nokogiri::XML::Element, String then Nokogiri::XML.fragment(fragment)
    else fail ArgumentError
  end
end

Instance Method Details

#to_uuidString

Returns UUIDv3.

Returns:

  • (String)

    UUIDv3


29
30
31
# File 'lib/aixm/payload_hash.rb', line 29

def to_uuid
  uuid_for payload_array
end