class ItuBib::Hit

Hit.

Attributes

hit[R]

@return [Array<Hash>]

hit_collection[R]

@return [Isobib::HitCollection]

Public Class Methods

new(hit, hit_collection = nil) click to toggle source

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

# File lib/itubib/hit.rb, line 14
def initialize(hit, hit_collection = nil)
  @hit            = hit
  @hit_collection = hit_collection
end

Public Instance Methods

fetch() click to toggle source

Parse page. @return [Isobib::IsoBibliographicItem]

# File lib/itubib/hit.rb, line 21
def fetch
  @fetch ||= Scrapper.parse_page @hit
end
inspect() click to toggle source

@return [String]

# File lib/itubib/hit.rb, line 31
def inspect
  "<#{self.class}:#{format('%#.14x', object_id << 1)} "\
  "@text=\"#{@hit_collection&.text}\" "\
  "@fetched=\"#{!@fetch.nil?}\" "\
  "@fullIdentifier=\"#{@fetch&.shortref(nil)}\" "\
  "@title=\"#{@hit[:code]}\">"
end
to_s() click to toggle source

@return [String]

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

@return [String]

# File lib/itubib/hit.rb, line 40
def to_xml(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