Class: Puree::XMLExtractor::JournalArticle

Inherits:
ResearchOutput show all
Includes:
PageRangeMixin, PagesMixin, PeerReviewedMixin
Defined in:
lib/puree/xml_extractor/journal_article.rb

Overview

Journal article XML extractor.

Instance Method Summary collapse

Methods included from PeerReviewedMixin

#peer_reviewed

Methods included from PageRangeMixin

#page_range

Methods included from PagesMixin

#pages

Methods inherited from ResearchOutput

#bibliographical_note, #category, #doi, #dois, #files, #keywords, #language, #links, #open_access_permission, #persons_external, #persons_internal, #persons_other, #publication_statuses, #scopus_citations_count, #scopus_id, #scopus_metrics, #subtitle, #title, #translated_subtitle, #translated_title

Methods included from TypeMixin

#type

Methods included from WorkflowMixin

#workflow

Methods included from ResearchOutputMixin

#research_outputs

Methods included from ProjectMixin

#projects

Methods included from OwnerMixin

#owner

Methods included from OrganisationalUnitMixin

#organisational_units

Methods included from AbstractMixin

#description

Methods inherited from Resource

#created_at, #created_by, #id, #model, #modified_at, #modified_by, #previous_uuids, #uuid

Methods inherited from Base

#xpath_query_for_multi_value, #xpath_query_for_single_value

Constructor Details

#initialize(xml) ⇒ JournalArticle

Returns a new instance of JournalArticle.



11
12
13
14
# File 'lib/puree/xml_extractor/journal_article.rb', line 11

def initialize(xml)
  super
  setup_model :journal_article
end

Instance Method Details

#issueInteger?

Returns:

  • (Integer, nil)


17
18
19
20
# File 'lib/puree/xml_extractor/journal_article.rb', line 17

def issue
  xpath_result = xpath_query_for_single_value('/journalNumber')
  xpath_result ? xpath_result.to_i : nil
end

#journalPuree::Model::JournalHeader?

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/puree/xml_extractor/journal_article.rb', line 23

def journal
  xpath_result = xpath_query '/journalAssociation'
  if !xpath_result.empty?
    header = Puree::Model::JournalHeader.new
    header.title = xpath_result.xpath('title').text.strip
    journal = xpath_result.xpath('journal')
    xpath_result_type = journal.xpath('types/type')
    header.type = xpath_result_type.first.text.strip unless xpath_result_type.empty?
    header.uuid = journal.attr('uuid').text.strip
    header
  end
end

#volumeInteger?

Returns:

  • (Integer, nil)


37
38
39
40
# File 'lib/puree/xml_extractor/journal_article.rb', line 37

def volume
  xpath_result = xpath_query_for_single_value('/volume')
  xpath_result ? xpath_result.to_i : nil
end