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

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

Parse page.

Parameters:

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

Returns:

  • (RelatonIso::IsoBibliographicItem)


24
25
26
27
28
29
# File 'lib/relaton_iso/hit.rb', line 24

def fetch(lang = nil)
  @fetch ||= Scrapper.parse_page self, lang
  # update edition for pubid using fetched data
  update_edition(@fetch)
  @fetch
end

#pubidPubid::Iso::Identifier

Returns:

  • (Pubid::Iso::Identifier)


43
44
45
46
47
48
49
# File 'lib/relaton_iso/hit.rb', line 43

def pubid
  @pubid ||= Pubid::Iso::Identifier.parse_from_title(hit[:title])
rescue Pubid::Iso::Errors::WrongTypeError,
       Pubid::Iso::Errors::ParseError => e
  Util.warn "Unable to find an identifier in: `#{hit[:title]}`."
  Util.warn e.message
end

Instance Method Details

#sort_weightInteger

Returns:

  • (Integer)


32
33
34
35
36
37
38
39
40
# File 'lib/relaton_iso/hit.rb', line 32

def sort_weight
  case hit[:status] # && hit["publicationStatus"]["key"]
  when "Published" then 0
  when "Under development" then 1
  when "Withdrawn" then 2
  when "Deleted" then 3
  else 4
  end
end

#update_edition(bibliographic_item) ⇒ Object

Update edition for pubid when provided in Bibliographic Item



10
11
12
13
14
15
16
17
18
19
# File 'lib/relaton_iso/hit.rb', line 10

def update_edition(bibliographic_item)
  if bibliographic_item.edition
    # add edition to base document if available
    if pubid.base
      pubid.base.edition = bibliographic_item.edition.content
    else
      pubid.edition = bibliographic_item.edition.content
    end
  end
end