Class: Openlibrary::Covers::Image
- Inherits:
-
Object
- Object
- Openlibrary::Covers::Image
- Defined in:
- lib/openlibrary/covers.rb
Overview
An Image from the OpenLibrary API, if one exists
Instance Method Summary collapse
- #found? ⇒ Boolean
-
#initialize(identifiers, identifier_type = :isbn) ⇒ Image
constructor
A new instance of Image.
- #url(size = 'M') ⇒ Object
Constructor Details
#initialize(identifiers, identifier_type = :isbn) ⇒ Image
Returns a new instance of Image.
14 15 16 17 18 19 20 21 22 |
# File 'lib/openlibrary/covers.rb', line 14 def initialize(identifiers, identifier_type = :isbn) identifiers = Array(identifiers) @identifier_type = identifier_type @found = false @successful_identifier = identifiers.detect { |identifier| image_exists(identifier) } @found = true if @successful_identifier end |
Instance Method Details
#found? ⇒ Boolean
24 25 26 |
# File 'lib/openlibrary/covers.rb', line 24 def found? @found end |
#url(size = 'M') ⇒ Object
30 31 32 |
# File 'lib/openlibrary/covers.rb', line 30 def url(size = 'M') @found ? openlibrary_url(@successful_identifier, size) : nil end |