Sha256: 9170ac939dccd30d125fe97a59c291535829dc8593aa0a096586b00e869c7053

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 KB

Contents

module Puree
  module XMLExtractor

    # Journal article XML extractor.
    #
    class JournalArticle < Puree::XMLExtractor::ResearchOutput
      include Puree::XMLExtractor::PagesMixin
      include Puree::XMLExtractor::PageRangeMixin
      include Puree::XMLExtractor::PeerReviewedMixin

      def initialize(xml)
        super
        setup_model :journal_article
      end

      # @return [Integer, nil]
      def issue
        xpath_result = xpath_query_for_single_value('/journalNumber')
        xpath_result ? xpath_result.to_i : nil
      end

      # @return [Puree::Model::JournalHeader, nil]
      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')
          header.type = journal.xpath('type').text.strip
          header.uuid = journal.attr('uuid').text.strip
          header
        end
      end

      # @return [Integer, nil]
      def volume
        xpath_result = xpath_query_for_single_value('/volume')
        xpath_result ? xpath_result.to_i : nil
      end


      private

      def xpath_root
        '/contributionToJournal'
      end

      def combine_metadata
        super
        @model.issue = issue
        @model.journal = journal
        @model.pages = pages
        @model.page_range = page_range
        @model.peer_reviewed = peer_reviewed
        @model.volume = volume
        @model
      end      

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
puree-2.7.0 lib/puree/xml_extractor/journal_article.rb
puree-2.6.0 lib/puree/xml_extractor/journal_article.rb
puree-2.5.1 lib/puree/xml_extractor/journal_article.rb
puree-2.5.0 lib/puree/xml_extractor/journal_article.rb
puree-2.4.0 lib/puree/xml_extractor/journal_article.rb
puree-2.3.0 lib/puree/xml_extractor/journal_article.rb