Sha256: b8b3459c3f3fc87548006f84d54515f087e2a69f12444e66ebcdfab92c45c734

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 Bytes

Contents

# frozen_string_literal: true

module RelatonIso
  # Hit.
  class Hit < RelatonBib::Hit
    # @return [RelatonIsoBib::IsoBibliographicItem]
    attr_writer :fetch, :pubid

    # Parse page.
    # @param lang [String, NilClass]
    # @return [RelatonIso::IsoBibliographicItem]
    def fetch(lang = nil, all_parts = false)
      @fetch ||= Scrapper.parse_page @hit, lang, all_parts
    end

    # @return [Integer]
    def sort_weight
      case hit[:status] # && hit["publicationStatus"]["key"]
      when "Published" then 0
      when "Under development" then 1
      when "Withdrawn" then 2
      when "Deleted" then 3
      else 4
      end
    end

    # @return [Pubid::Iso::Identifier]
    def pubid
      Pubid::Iso::Identifier.parse_from_title(hit[:title])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relaton-iso-1.12.0 lib/relaton_iso/hit.rb