Class: Gbbib::Hit
- Inherits:
-
Object
- Object
- Gbbib::Hit
- Defined in:
- lib/gbbib/hit.rb
Overview
Hit.
Instance Attribute Summary collapse
- #hit_collection ⇒ Isobib::HitCollection readonly
- #pid ⇒ String readonly
- #scrapper ⇒ Gbbib::GbScrapper, ... readonly
- #title ⇒ String readonly
Instance Method Summary collapse
-
#fetch ⇒ Isobib::IsoBibliographicItem
Parse page.
-
#initialize(pid:, title:, hit_collection: nil, scrapper:) ⇒ Hit
constructor
A new instance of Hit.
- #inspect ⇒ String
- #to_s ⇒ String
- #to_xml(builder = nil, opts = {}) ⇒ String
Constructor Details
#initialize(pid:, title:, hit_collection: nil, scrapper:) ⇒ Hit
Returns a new instance of Hit.
20 21 22 23 24 25 26 |
# File 'lib/gbbib/hit.rb', line 20 def initialize(pid:, title:, hit_collection: nil, scrapper:) @pid = pid @title = title @hit_collection = hit_collection @scrapper = scrapper self.hit_collection << self if hit_collection end |
Instance Attribute Details
#hit_collection ⇒ Isobib::HitCollection (readonly)
7 8 9 |
# File 'lib/gbbib/hit.rb', line 7 def hit_collection @hit_collection end |
#pid ⇒ String (readonly)
10 11 12 |
# File 'lib/gbbib/hit.rb', line 10 def pid @pid end |
#scrapper ⇒ Gbbib::GbScrapper, ... (readonly)
16 17 18 |
# File 'lib/gbbib/hit.rb', line 16 def scrapper @scrapper end |
#title ⇒ String (readonly)
13 14 15 |
# File 'lib/gbbib/hit.rb', line 13 def title @title end |
Instance Method Details
#fetch ⇒ Isobib::IsoBibliographicItem
Parse page.
30 31 32 |
# File 'lib/gbbib/hit.rb', line 30 def fetch @fetch ||= scrapper.scrape_doc pid end |
#inspect ⇒ String
40 41 42 43 44 |
# File 'lib/gbbib/hit.rb', line 40 def inspect "<#{self.class}:#{format('%#.14x', object_id << 1)} "\ "@fullIdentifier=\"#{@fetch&.shortref}\" "\ "@title=\"#{title}\">" end |
#to_s ⇒ String
35 36 37 |
# File 'lib/gbbib/hit.rb', line 35 def to_s inspect end |
#to_xml(builder = nil, opts = {}) ⇒ String
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/gbbib/hit.rb', line 47 def to_xml(builder = nil, 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 |