class RelatonIsoBib::XMLParser

Private Class Methods

bib_item(item_hash) click to toggle source

override RelatonBib::BibliographicItem.bib_item method @param item_hash [Hash] @return [RelatonIsoBib::IsoBibliographicItem]

# File lib/relaton_iso_bib/xml_parser.rb, line 25
def bib_item(item_hash)
  IsoBibliographicItem.new(**item_hash)
end
fetch_editorialgroup(ext) click to toggle source

@TODO Organization doesn't recreated @param ext [Nokogiri::XML::Element] @return [RelatonIsoBib::EditorialGroup]

# File lib/relaton_iso_bib/xml_parser.rb, line 46
def fetch_editorialgroup(ext) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/AbcSize,Metrics/PerceivedComplexity
  eg = ext&.at("./editorialgroup")
  return unless eg

  tc = eg&.xpath("technical-committee")&.map { |t| iso_subgroup(t) }
  sc = eg&.xpath("subcommittee")&.map { |s| iso_subgroup(s) }
  wg = eg&.xpath("workgroup")&.map { |w| iso_subgroup(w) }
  sr = eg&.at "secretariat"
  EditorialGroup.new(technical_committee: tc, subcommittee: sc,
                     workgroup: wg, secretariat: sr&.text)
end
fetch_structuredidentifier(ext) click to toggle source

@param ext [Nokogiri::XML::Element] @return [RelatonIsoBib::StructuredIdentifier]

# File lib/relaton_iso_bib/xml_parser.rb, line 31
def fetch_structuredidentifier(ext)
  sid = ext&.at "./structuredidentifier"
  return unless sid

  pn = sid.at "project-number"
  tdn = sid.at "tc-document-number"
  RelatonIsoBib::StructuredIdentifier.new(
    type: sid[:type], project_number: pn.text, part: pn[:part],
    subpart: pn[:subpart], tc_document_number: tdn&.text
  )
end
iso_subgroup(com) click to toggle source

@param com [Nokogiri::XML::Element] @return [RelatonIsoBib::IsoSubgroup]

# File lib/relaton_iso_bib/xml_parser.rb, line 60
def iso_subgroup(com)
  return nil if com.nil?

  RelatonBib::WorkGroup.new(name: com.text, type: com[:type],
                            number: com[:number]&.to_i)
end
item_data(isoitem) click to toggle source

Override RelatonBib::XMLParser.item_data method. @param isoitem [Nokogiri::XML::Element] @returtn [Hash]

Calls superclass method
# File lib/relaton_iso_bib/xml_parser.rb, line 11
def item_data(isoitem)
  data = super
  ext = isoitem.at "./ext"
  return data unless ext

  hrzt = ext.at("./horizontal")
  data[:horizontal] = hrzt.text == "true" if hrzt
  data[:stagename] = ext.at("./stagename")&.text
  data
end