Class: Relaton::Ecma::MementoParser

Inherits:
Object
  • Object
show all
Includes:
ParserCommon
Defined in:
lib/relaton/ecma/memento_parser.rb

Constant Summary collapse

ATTRS =
%i[docidentifier title date source ext].freeze

Instance Method Summary collapse

Methods included from ParserCommon

#contributor, #default_bib_hash, #fetch_doctype, #fetch_ext

Constructor Details

#initialize(hit:, errors: {}) ⇒ MementoParser

Returns a new instance of MementoParser.

Parameters:

  • hit (Nokogiri::XML::Element)

    document hit

  • errors (Hash) (defaults to: {})

    error tracking hash



10
11
12
13
# File 'lib/relaton/ecma/memento_parser.rb', line 10

def initialize(hit:, errors: {})
  @hit = hit
  @errors = errors
end

Instance Method Details

#to_bib_hashHash

Returns bibliographic item attributes.

Returns:

  • (Hash)

    bibliographic item attributes



16
17
18
19
20
# File 'lib/relaton/ecma/memento_parser.rb', line 16

def to_bib_hash
  bib = default_bib_hash
  ATTRS.each { |a| bib[a] = send "fetch_#{a}" }
  bib
end