Sha256: e164c796e33ab5d1ca8236b6132c99aa0fa6d9d37174fce0e61a7d7bc162c8b4

Contents?: true

Size: 947 Bytes

Versions: 4

Compression:

Stored size: 947 Bytes

Contents

# frozen_string_literal: true

module NistBib
  # Hit.
  class Hit
    # @return [NistBib::HitCollection]
    attr_reader :hit_collection

    # @return [Array<Hash>]
    attr_reader :hit

    # @param hit [Hash]
    # @param hit_collection [NistBib:HitCollection]
    def initialize(hit, hit_collection = nil)
      @hit            = hit
      @hit_collection = hit_collection
    end

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

    # @return [String]
    def to_s
      inspect
    end

    # @return [String]
    def inspect
      "<#{self.class}:#{format('%#.14x', object_id << 1)} "\
      "@text=\"#{@hit_collection&.text}\" "\
      "@fetched=\"#{!@fetch.nil?}\" "\
      "@fullIdentifier=\"#{@fetch&.shortref(nil)}\" "\
      "@title=\"#{@hit[:code]}\">"
    end

    # @return [String]
    def to_xml(**opts)
      fetch.to_xml **opts
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
nistbib-0.1.9 lib/nistbib/hit.rb
nistbib-0.1.8 lib/nistbib/hit.rb
nistbib-0.1.7 lib/nistbib/hit.rb
nistbib-0.1.6 lib/nistbib/hit.rb