Class: RelatonIsbn::Parser

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

Overview

OpenLibrary document parser.

Constant Summary collapse

ATTRS =
i[fetched title docid link contributor date place].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ Parser

Returns a new instance of Parser.



8
9
10
# File 'lib/relaton_isbn/parser.rb', line 8

def initialize(doc)
  @doc = doc
end

Class Method Details

.parse(doc) ⇒ Object



12
13
14
# File 'lib/relaton_isbn/parser.rb', line 12

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

Instance Method Details

#parseObject



16
17
18
19
# File 'lib/relaton_isbn/parser.rb', line 16

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