Module: Puree::XMLExtractor::Shared

Defined in:
lib/puree/xml_extractor/shared.rb

Overview

Shared XML extractor.

Class Method Summary collapse

Class Method Details

.external_organisation_header(nokogiri_xml_element) ⇒ Puree::Model::ExternalOrganisationHeader



10
11
12
13
14
15
16
# 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
  h.name = nokogiri_xml_element.xpath('name').text.strip
  h.type = nokogiri_xml_element.xpath('type').text.strip
  h.data? ? h : nil
end

.external_organisation_multi_header(nokogiri_xml_nodeset) ⇒ Array<Puree::Model::ExternalOrganisationHeader>



19
20
21
22
23
24
25
26
# File 'lib/puree/xml_extractor/shared.rb', line 19

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) ⇒ Puree::Model::OrganisationalUnitHeader



29
30
31
32
33
34
35
# File 'lib/puree/xml_extractor/shared.rb', line 29

def self.organisation_header(nokogiri_xml_element)
  h = Puree::Model::OrganisationalUnitHeader.new
  h.uuid = nokogiri_xml_element.xpath('@uuid').text.strip
  h.name = nokogiri_xml_element.xpath('name').text.strip
  h.type = nokogiri_xml_element.xpath('type').text.strip
  h.data? ? h : nil
end

.organisation_multi_header(nokogiri_xml_nodeset) ⇒ Array<Puree::Model::OrganisationalUnitHeader>



38
39
40
41
42
43
44
45
# File 'lib/puree/xml_extractor/shared.rb', line 38

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