Class: Relaton::Core::Hit

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton/core/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 (RelatonBib::HitCollection) (defaults to: nil)


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

def initialize(hit, hit_collection = nil)
  @hit            = hit
  @hit_collection = WeakRef.new hit_collection if hit_collection
end

Instance Attribute Details

#hitArray<Hash> (readonly)

Returns:

  • (Array<Hash>)


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

def hit
  @hit
end

#hit_collectionRelatonBib::HitCollection

Returns:

  • (RelatonBib::HitCollection)


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

def hit_collection
  @hit_collection
end

Instance Method Details

#fetched?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/relaton/core/hit.rb', line 37

def fetched?
  !@item.nil?
end

#inspectString

Returns:

  • (String)


25
26
27
28
29
30
# File 'lib/relaton/core/hit.rb', line 25

def inspect
  "<#{self.class}:#{format('%<id>#.14x', id: object_id << 1)} " \
    "@reference=\"#{@hit_collection&.ref}\" " \
    "@fetched=\"#{fetched?}\" " \
    "@docidentifier=\"#{@hit[:code]}\">"
end

#itemRelatonBib::ItemData

Returns:

  • (RelatonBib::ItemData)


33
34
35
# File 'lib/relaton/core/hit.rb', line 33

def item
  raise "Not implemented"
end

#to_sString

Returns:

  • (String)


20
21
22
# File 'lib/relaton/core/hit.rb', line 20

def to_s
  inspect
end