Class: RelatonBib::Hit
Instance Attribute Summary collapse
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(hit, hit_collection = nil) ⇒ Hit
constructor
A new instance of Hit.
- #inspect ⇒ String
- #to_s ⇒ String
-
#to_xml(**opts) ⇒ String
XML.
Constructor Details
#initialize(hit, hit_collection = nil) ⇒ Hit
Returns a new instance of Hit.
13 14 15 16 |
# File 'lib/relaton_bib/hit.rb', line 13 def initialize(hit, hit_collection = nil) @hit = hit @hit_collection = WeakRef.new hit_collection if hit_collection end |
Instance Attribute Details
#hit_collection ⇒ RelatonBib::HitCollection
6 7 8 |
# File 'lib/relaton_bib/hit.rb', line 6 def hit_collection @hit_collection end |
Instance Method Details
#fetch ⇒ Object
32 33 34 |
# File 'lib/relaton_bib/hit.rb', line 32 def fetch raise "Not implemented" end |
#inspect ⇒ String
24 25 26 27 28 29 30 |
# File 'lib/relaton_bib/hit.rb', line 24 def inspect "<#{self.class}:#{format('%<id>#.14x', id: object_id << 1)} " \ "@text=\"#{@hit_collection&.text}\" " \ "@fetched=\"#{!@fetch.nil?}\" " \ "@fullIdentifier=\"#{@fetch&.shortref(nil)}\" " \ "@title=\"#{@hit[:code]}\">" end |
#to_s ⇒ String
19 20 21 |
# File 'lib/relaton_bib/hit.rb', line 19 def to_s inspect end |
#to_xml(**opts) ⇒ String
Returns XML.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/relaton_bib/hit.rb', line 41 def to_xml(**opts) if opts[:builder] fetch.to_xml(**opts) else builder = Nokogiri::XML::Builder.new(encoding: "UTF-8") do |xml| fetch.to_xml(**opts.merge(builder: xml)) end builder.doc.root.to_xml end end |