Class: OpenLibraryBook
- Inherits:
-
OpenLibraryEntry
- Object
- OpenLibraryEntry
- OpenLibraryBook
- Defined in:
- lib/fetchworks.rb
Overview
A class that represents books in the OpenLibrary database It exposes the JSON representation that OL provides through their API as a hash through @data, and as methods with method_missing, and handles some comple
Instance Attribute Summary
Attributes inherited from OpenLibraryEntry
Instance Method Summary collapse
- #fetch_authors ⇒ Object
-
#initialize(ident) ⇒ OpenLibraryBook
constructor
Identifier is assumed to be ISBN10/ISBN13 TODO: Add a check or identification type.
- #publish_date ⇒ Object
Methods included from HashMethodable
#method_missing, #respond_to_missing?
Constructor Details
#initialize(ident) ⇒ OpenLibraryBook
Identifier is assumed to be ISBN10/ISBN13 TODO: Add a check or identification type
180 181 182 |
# File 'lib/fetchworks.rb', line 180 def initialize(ident) super OpenLibrary.get_book(ident) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class HashMethodable
Instance Method Details
#fetch_authors ⇒ Object
189 190 191 192 193 |
# File 'lib/fetchworks.rb', line 189 def .collect do || OpenLibraryAuthor.new ["url"] end end |
#publish_date ⇒ Object
184 185 186 187 |
# File 'lib/fetchworks.rb', line 184 def publish_date str = @data["publish_date"] OpenLibrary.partial_date_from_str(str) end |