Class: RelatonGb::Hit

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

Overview

Hit.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pid:, docref:, scrapper:, **args) ⇒ Hit

Returns a new instance of Hit.

Parameters:

  • pid (String)
  • docref (String)
  • release_date (String)
  • hit_collection (RelatonGb:HitCollection, NilClass)


27
28
29
30
31
32
33
34
# File 'lib/relaton_gb/hit.rb', line 27

def initialize(pid:, docref:, scrapper:, **args)
  @pid            = pid
  @docref         = docref
  @scrapper       = scrapper
  @release_date   = Date.parse args[:release_date] if args[:release_date]
  @status         = args[:status]
  @hit_collection = args[:hit_collection]
end

Instance Attribute Details

#docrefString (readonly)

Returns:

  • (String)


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

def docref
  @docref
end

#hit_collectionIsobib::HitCollection (readonly)

Returns:

  • (Isobib::HitCollection)


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

def hit_collection
  @hit_collection
end

#pidString (readonly)

Returns:

  • (String)


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

def pid
  @pid
end

#release_dateDate, NilClass (readonly)

Returns:

  • (Date, NilClass)


13
14
15
# File 'lib/relaton_gb/hit.rb', line 13

def release_date
  @release_date
end

#scrapperRelatonGb::GbScrapper, ... (readonly)

Returns:



19
20
21
# File 'lib/relaton_gb/hit.rb', line 19

def scrapper
  @scrapper
end

#statusString, NilClass (readonly)

Returns:

  • (String, NilClass)


16
17
18
# File 'lib/relaton_gb/hit.rb', line 16

def status
  @status
end

Instance Method Details

#fetchIsobib::IsoBibliographicItem

Parse page.

Returns:

  • (Isobib::IsoBibliographicItem)


38
39
40
# File 'lib/relaton_gb/hit.rb', line 38

def fetch
  @fetch ||= scrapper.scrape_doc self
end

#inspectString

Returns:

  • (String)


48
49
50
51
52
# File 'lib/relaton_gb/hit.rb', line 48

def inspect
  "<#{self.class}:#{format('%#.14x', object_id << 1)} "\
  "@fullIdentifier=\"#{@fetch&.shortref}\" "\
  "@docref=\"#{docref}\">"
end

#to_sString

Returns:

  • (String)


43
44
45
# File 'lib/relaton_gb/hit.rb', line 43

def to_s
  inspect
end