Class: NistBib::Hit

Inherits:
Object
  • Object
show all
Defined in:
lib/nistbib/hit.rb

Overview

Hit.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hit, hit_collection = nil) ⇒ Hit

Returns a new instance of Hit.

Parameters:

  • hit (Hash)
  • hit_collection (NistBib:HitCollection) (defaults to: nil)


14
15
16
17
# File 'lib/nistbib/hit.rb', line 14

def initialize(hit, hit_collection = nil)
  @hit            = hit
  @hit_collection = hit_collection
end

Instance Attribute Details

#hitArray<Hash> (readonly)

Returns:

  • (Array<Hash>)


10
11
12
# File 'lib/nistbib/hit.rb', line 10

def hit
  @hit
end

#hit_collectionNistBib::HitCollection (readonly)



7
8
9
# File 'lib/nistbib/hit.rb', line 7

def hit_collection
  @hit_collection
end

Instance Method Details

#fetchNistBib::NistBliographicItem

Parse page.

Returns:

  • (NistBib::NistBliographicItem)


21
22
23
# File 'lib/nistbib/hit.rb', line 21

def fetch
  @fetch ||= Scrapper.parse_page @hit
end

#inspectString

Returns:

  • (String)


31
32
33
34
35
36
37
# File 'lib/nistbib/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_sString

Returns:

  • (String)


26
27
28
# File 'lib/nistbib/hit.rb', line 26

def to_s
  inspect
end

#to_xml(**opts) ⇒ String

Returns:

  • (String)


40
41
42
# File 'lib/nistbib/hit.rb', line 40

def to_xml(**opts)
  fetch.to_xml **opts
end