Class: Relaton::Isbn::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton/isbn/parser.rb

Overview

OpenLibrary document parser.

Constant Summary collapse

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ Parser

Returns a new instance of Parser.



9
10
11
# File 'lib/relaton/isbn/parser.rb', line 9

def initialize(doc)
  @doc = doc
end

Class Method Details

.parse(doc) ⇒ Object



13
14
15
# File 'lib/relaton/isbn/parser.rb', line 13

def self.parse(doc)
  new(doc).parse
end

Instance Method Details

#parseObject



17
18
19
20
# File 'lib/relaton/isbn/parser.rb', line 17

def parse
  args = ATTRS.each_with_object({}) { |a, h| h[a] = send(a) }
  Bib::ItemData.new(**args)
end