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



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

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

UUIDv3

Returns:

  • (String)


32
33
34
# File 'lib/aixm/payload_hash.rb', line 32

def to_uuid
  uuid_for payload_array
end