Class: RelatonIso::Hit

Inherits:
RelatonBib::Hit
  • Object
show all
Defined in:
lib/relaton_iso/hit.rb

Overview

Hit.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hit_collectionRelatonIso::HitCollection (readonly)



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

def hit_collection
  @hit_collection
end

Instance Method Details

#fetch(lang = nil) ⇒ RelatonIso::IsoBibliographicItem

Parse page.

Parameters:

  • lang (String, NilClass) (defaults to: nil)

Returns:

  • (RelatonIso::IsoBibliographicItem)


12
13
14
# File 'lib/relaton_iso/hit.rb', line 12

def fetch(lang = nil)
  @fetch ||= Scrapper.parse_page @hit, lang
end

#sort_weightObject



28
29
30
31
32
33
34
35
36
# File 'lib/relaton_iso/hit.rb', line 28

def sort_weight
  case hit["publicationStatus"]
  when "Published" then 0
  when "Under development" then 1
  when "Withdrawn" then 2
  else
    3
  end
end

#to_xml(builder = nil, **opts) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder) (defaults to: nil)


17
18
19
20
21
22
23
24
25
26
# File 'lib/relaton_iso/hit.rb', line 17

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