class KindleCG::Collections

Attributes

collections[R]

Public Class Methods

new() click to toggle source
# File lib/KindleCG/collections.rb, line 5
def initialize
  @collections = {}
end

Public Instance Methods

add(name, language = 'en-US') click to toggle source
# File lib/KindleCG/collections.rb, line 9
def add(name, language = 'en-US')
  collection_name = "#{name}@#{language}"
  @collections[collection_name] = { items: [] } 
  collection_name
end
add_item_to_collection(collection_name, ebook) click to toggle source
# File lib/KindleCG/collections.rb, line 15
def add_item_to_collection(collection_name, ebook)
  @collections[collection_name][:items] << ebook.hash
end
to_json() click to toggle source
# File lib/KindleCG/collections.rb, line 19
def to_json
  JSON.generate(@collections)
end