class Gbbib::Hit

Hit.

Attributes

hit_collection[R]

@return [Isobib::HitCollection]

pid[R]

@return [String]

scrapper[R]

@return [Gbbib::GbScrapper, Gbbib::SecScraper, Gbbib::TScrapper]

title[R]

@return [String]

Public Class Methods

new(pid:, title:, hit_collection: nil, scrapper:) click to toggle source

@param hit [Hash] @param hit_collection [Isobib:HitCollection]

# File lib/gbbib/hit.rb, line 20
def initialize(pid:, title:, hit_collection: nil, scrapper:)
  @pid            = pid
  @title          = title
  @hit_collection = hit_collection
  @scrapper       = scrapper
  self.hit_collection << self if hit_collection
end

Public Instance Methods

fetch() click to toggle source

Parse page. @return [Isobib::IsoBibliographicItem]

# File lib/gbbib/hit.rb, line 30
def fetch
  @fetch ||= scrapper.scrape_doc pid
end
inspect() click to toggle source

@return [String]

# File lib/gbbib/hit.rb, line 40
def inspect
  "<#{self.class}:#{format('%#.14x', object_id << 1)} "\
  "@fullIdentifier=\"#{@fetch&.shortref}\" "\
  "@title=\"#{title}\">"
end
to_s() click to toggle source

@return [String]

# File lib/gbbib/hit.rb, line 35
def to_s
  inspect
end
to_xml(builder = nil, opts = {}) click to toggle source

@param builder [Nokogiri::XML::Builder] @param opts [Hash] @return [String]

# File lib/gbbib/hit.rb, line 49
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