module Puree::XMLExtractor::Shared

Shared XML extractor.

Public Class Methods

external_organisation_header(nokogiri_xml_element) click to toggle source

@return [Puree::Model::ExternalOrganisationHeader]

# File lib/puree/xml_extractor/shared.rb, line 10
def self.external_organisation_header(nokogiri_xml_element)
  h = Puree::Model::ExternalOrganisationHeader.new
  h.uuid = nokogiri_xml_element.xpath('@uuid').text.strip
  xpath_result_name = nokogiri_xml_element.xpath('name/text')
  h.name = xpath_result_name.first.text.strip unless xpath_result_name.empty?
  xpath_result_type = nokogiri_xml_element.xpath('type/term/text')
  h.type = xpath_result_type.first.text.strip unless xpath_result_type.empty?
  h.data? ? h : nil
end
external_organisation_multi_header(nokogiri_xml_nodeset) click to toggle source

@return [Array<Puree::Model::ExternalOrganisationHeader>]

# File lib/puree/xml_extractor/shared.rb, line 21
def self.external_organisation_multi_header(nokogiri_xml_nodeset)
  data = []
  nokogiri_xml_nodeset.each do |i|
    header =  external_organisation_header(i)
    data << header if header
  end
  data.uniq { |d| d.uuid }
end
organisation_header(nokogiri_xml_element) click to toggle source

@return [Puree::Model::OrganisationalUnitHeader]

# File lib/puree/xml_extractor/shared.rb, line 31
def self.organisation_header(nokogiri_xml_element)
  h = Puree::Model::OrganisationalUnitHeader.new
  h.uuid = nokogiri_xml_element.xpath('@uuid').text.strip
  xpath_result_name = nokogiri_xml_element.xpath('name/text')
  h.name = xpath_result_name.first.text.strip unless xpath_result_name.empty?
  xpath_result_type = nokogiri_xml_element.xpath('type/term/text')
  h.type = xpath_result_type.first.text.strip unless xpath_result_type.empty?
  h.data? ? h : nil
end
organisation_multi_header(nokogiri_xml_nodeset) click to toggle source

@return [Array<Puree::Model::OrganisationalUnitHeader>]

# File lib/puree/xml_extractor/shared.rb, line 42
def self.organisation_multi_header(nokogiri_xml_nodeset)
  data = []
  nokogiri_xml_nodeset.each do |i|
    header = organisation_header(i)
    data << header if header
  end
  data.uniq { |d| d.uuid }
end