Sha256: b1b1b367004ba2ca7726fb3591824b245ff55a600b9f3f47de6b9a6a697717e3

Contents?: true

Size: 818 Bytes

Versions: 8

Compression:

Stored size: 818 Bytes

Contents

# frozen_string_literal: true

module RelatonIso
  # Hit.
  class Hit < RelatonBib::Hit
    # @return [RelatonIso::HitCollection]
    attr_reader :hit_collection

    # Parse page.
    # @return [RelatonIso::IsoBibliographicItem]
    def fetch
      @fetch ||= Scrapper.parse_page @hit
    end

    # @param builder [Nokogiri::XML::Builder]
    def to_xml(builder = nil, **opts)
      if builder
        fetch.to_xml builder, **opts
      else
        builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml|
          fetch.to_xml xml, **opts
        end
        builder.doc.root.to_xml
      end
    end

    def sort_weight
      case hit["publicationStatus"]
      when "Published" then 0
      when "Under development" then 1
      when "Withdrawn" then 2
      else
        3
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
relaton-iso-0.8.0 lib/relaton_iso/hit.rb
relaton-iso-0.7.1 lib/relaton_iso/hit.rb
relaton-iso-0.7.0 lib/relaton_iso/hit.rb
relaton-iso-0.6.10 lib/relaton_iso/hit.rb
relaton-iso-0.6.9 lib/relaton_iso/hit.rb
relaton-iso-0.6.8 lib/relaton_iso/hit.rb
relaton-iso-0.6.7 lib/relaton_iso/hit.rb
relaton-iso-0.6.6 lib/relaton_iso/hit.rb