Sha256: 6eb352f61bd0b2c1673c4e1ec88b8c4dc2f6533f5062d9945c0c76a04428be08

Contents?: true

Size: 758 Bytes

Versions: 11

Compression:

Stored size: 758 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, nil]
    # @return [RelatonIso::IsoBibliographicItem]
    def fetch(lang = nil)
      @fetch ||= Scrapper.parse_page self, lang
    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 ||= Pubid::Iso::Identifier.parse_from_title(hit[:title])
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
relaton-iso-1.13.6 lib/relaton_iso/hit.rb
relaton-iso-1.13.5 lib/relaton_iso/hit.rb
relaton-iso-1.13.4 lib/relaton_iso/hit.rb
relaton-iso-1.13.3 lib/relaton_iso/hit.rb
relaton-iso-1.13.2 lib/relaton_iso/hit.rb
relaton-iso-1.13.1 lib/relaton_iso/hit.rb
relaton-iso-1.13.0 lib/relaton_iso/hit.rb
relaton-iso-1.12.4 lib/relaton_iso/hit.rb
relaton-iso-1.12.3 lib/relaton_iso/hit.rb
relaton-iso-1.12.2 lib/relaton_iso/hit.rb
relaton-iso-1.12.1 lib/relaton_iso/hit.rb