Module: HQMF2::Utilities

Includes:
HQMF::Conversion::Utilities
Included in:
Coded, DataCriteria, Document, PopulationCriteria, Precondition, Range, Reference, SubsetOperator, TemporalReference, Value
Defined in:
lib/hqmf-parser/2.0/utilities.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HQMF::Conversion::Utilities

#build_hash, #check_equality, #json_array, #openstruct_to_json

Class Method Details

.attr_val(node, xpath) ⇒ Object

Utility function to handle optional attributes

Parameters:

  • xpath

    an XPath that identifies an XML attribute

Returns:

  • the value of the attribute or nil if the attribute is missing



16
17
18
19
20
21
22
23
# File 'lib/hqmf-parser/2.0/utilities.rb', line 16

def self.attr_val(node, xpath)
  attr = node.at_xpath(xpath, HQMF2::Document::NAMESPACES)
  if attr
    attr.value
  else
    nil
  end
end

Instance Method Details

#attr_val(xpath) ⇒ Object

Utility function to handle optional attributes

Parameters:

  • xpath

    an XPath that identifies an XML attribute

Returns:

  • the value of the attribute or nil if the attribute is missing



9
10
11
# File 'lib/hqmf-parser/2.0/utilities.rb', line 9

def attr_val(xpath)
  Utilities::attr_val(@entry, xpath)
end

#to_xmlObject



25
26
27
# File 'lib/hqmf-parser/2.0/utilities.rb', line 25

def to_xml
  @entry.to_xml
end