Class: RelatonBib::Hit

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

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 (RelatonIso::HitCollection, RelatonNist:HitCollection) (defaults to: nil)


8
9
10
11
# File 'lib/relaton_bib/hit.rb', line 8

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

Instance Attribute Details

#hitArray<Hash> (readonly)

Returns:

  • (Array<Hash>)


4
5
6
# File 'lib/relaton_bib/hit.rb', line 4

def hit
  @hit
end

Instance Method Details

#inspectString

Returns:

  • (String)


19
20
21
22
23
24
25
# File 'lib/relaton_bib/hit.rb', line 19

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)


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

def to_s
  inspect
end

#to_xml(**opts) ⇒ String

Returns:

  • (String)


28
29
30
# File 'lib/relaton_bib/hit.rb', line 28

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