Sha256: fa6027513374ba2d3402d845d233ae95c05a9209ed12ad4514cd119b35272f6b

Contents?: true

Size: 672 Bytes

Versions: 2

Compression:

Stored size: 672 Bytes

Contents

module Puree

  module XMLExtractor

    # Publisher extractor mixin.
    #
    module PublisherMixin

      # @return [Puree::Model::PublisherHeader, nil]
      def publisher
        xpath_result = xpath_query '/publisher'
        h = Puree::Model::PublisherHeader.new
        h.uuid = xpath_result.xpath('@uuid').text.strip
        xpath_result_name = xpath_result.xpath('names/name')
        h.name = xpath_result_name.first.text.strip unless xpath_result_name.empty?
        xpath_result_type = xpath_result.xpath('types/type')
        h.type = xpath_result_type.first.text.strip unless xpath_result_type.empty?
        h.data? ? h : nil
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puree-2.8.1 lib/puree/xml_extractor/mixins/publisher_mixin.rb
puree-2.8.0 lib/puree/xml_extractor/mixins/publisher_mixin.rb