Class: RelatonBib::Hit
Instance Attribute Summary collapse
- #hit ⇒ Array<Hash> readonly
- #hit_collection ⇒ RelatonBib::HitCollection readonly
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.
11 12 13 14 |
# File 'lib/relaton_bib/hit.rb', line 11 def initialize(hit, hit_collection = nil) @hit = hit @hit_collection = hit_collection end |
Instance Attribute Details
#hit_collection ⇒ RelatonBib::HitCollection (readonly)
4 5 6 |
# File 'lib/relaton_bib/hit.rb', line 4 def hit_collection @hit_collection end |
Instance Method Details
#fetch ⇒ Object
30 31 32 |
# File 'lib/relaton_bib/hit.rb', line 30 def fetch raise "Not implemented" end |
#inspect ⇒ String
22 23 24 25 26 27 28 |
# File 'lib/relaton_bib/hit.rb', line 22 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
17 18 19 |
# File 'lib/relaton_bib/hit.rb', line 17 def to_s inspect end |
#to_xml(**opts) ⇒ String
Returns XML.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/relaton_bib/hit.rb', line 39 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 |