Module: Alexandrite

Includes:
ErrorType
Defined in:
lib/alexandrite.rb,
lib/helpers/format.rb,
lib/alexandrite_oclc.rb,
lib/alexandrite_books.rb,
lib/alexandrite_google.rb,
lib/helpers/validation.rb,
lib/alexandrite/version.rb,
lib/alexandrite_bookshelf.rb

Overview

Create, Read, Update and Delete books in a book collection

Defined Under Namespace

Modules: GoogleAPI, Helpers, OCLCAPI Classes: Book, Bookshelf, Google, OCLC

Constant Summary collapse

API =
{
  google: Alexandrite::Google,
  oclc: Alexandrite::OCLC
}.freeze
VERSION =
'0.0.1'

Instance Method Summary collapse

Instance Method Details

#add_book(book) ⇒ Object



14
# File 'lib/alexandrite_bookshelf.rb', line 14

def add_book(book) = @book_collection << book if

#bulk_create(isbns) ⇒ Nil

Parameters:

  • isbns (Array)

Returns:

  • (Nil)


67
68
69
70
71
72
73
74
# File 'lib/alexandrite.rb', line 67

def bulk_create(isbns)
  isbns.each do |isbn|
    volume_info = volume_info(isbn)
    book = Alexandrite::Book.new(volume_info)
    add_to_collection(book)
  end
  nil
end

#create_book(key, query) ⇒ Object



58
59
60
61
62
63
# File 'lib/alexandrite.rb', line 58

def create_book(key, query)
  book = API[:google].create_book(query)
  return API[:oclc].create_book(key, query) if book.error_message

  book
end

#search_by(key, query, api: :google) ⇒ Object



54
55
56
# File 'lib/alexandrite.rb', line 54

def search_by(key, query, api: :google)
  API[api].search_by(key, query)
end