Class: AIXM::Feature::Generic

Inherits:
AIXM::Feature show all
Defined in:
lib/aixm/feature/generic.rb

Overview

Generic feature represented as XML document fragment.

Cheat Sheet in Pseudo Code:

generic = AIXM.generic(
  fragment: Nokogiri::XML::DocumentFragment or String
)

Constant Summary

Constants inherited from AIXM::Feature

REGION_RE

Instance Attribute Summary collapse

Attributes inherited from AIXM::Feature

#comment, #region, #source

Attributes inherited from Component

#meta

Instance Method Summary collapse

Methods inherited from AIXM::Feature

#==, #hash

Methods included from Concerns::HashEquality

#eql?, #hash

Methods included from Concerns::XMLBuilder

#build_fragment, #to_xml

Methods included from Concerns::Memoize

included, method

Constructor Details

#initialize(source: nil, region: nil, fragment:) ⇒ Generic

See the cheat sheet for examples on how to create instances of this class.



26
27
28
29
# File 'lib/aixm/feature/generic.rb', line 26

def initialize(source: nil, region: nil, fragment:)
  super(source: source, region: region)
  self.fragment = fragment
end

Instance Attribute Details

#fragmentNokogiri::XML::DocumentFragment #fragment=(value) ⇒ Object

XML document fragment

Overloads:

  • #fragmentNokogiri::XML::DocumentFragment

    Returns:

    • (Nokogiri::XML::DocumentFragment)
  • #fragment=(value) ⇒ Object

    Parameters:

    • value (Nokogiri::XML::DocumentFragment, Object)

      XML document fragment or object which is converted to string and then parsed



22
23
24
# File 'lib/aixm/feature/generic.rb', line 22

def fragment
  @fragment
end

Instance Method Details

#inspectString

Returns:

  • (String)


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

def inspect
  %Q(#<#{self.class} #{fragment.elements.first.name}>)
end

#to_uidInteger

Returns pseudo UID fragment.

Returns:

  • (Integer)

    pseudo UID fragment



44
45
46
# File 'lib/aixm/feature/generic.rb', line 44

def to_uid
  fragment.to_xml.hash
end