class BookInfo

Attributes

book[RW]
items[RW]
subtitles[RW]
titles[RW]

Public Class Methods

new(items=[]) click to toggle source
# File lib/google_book/book_info.rb, line 7
def initialize(items=[])
  @items = items
end

Public Instance Methods

get_all_sub_titles() click to toggle source

return all the subtitles

# File lib/google_book/book_info.rb, line 18
def get_all_sub_titles
  show_all_titles_and_subtitles("subtitle")
  return @subtitles
end
get_all_titles() click to toggle source

return the all titles of those books

# File lib/google_book/book_info.rb, line 12
def get_all_titles
  show_all_titles_and_subtitles("title")
  return @titles
end
get_book(params = {}) click to toggle source

return the particular book

# File lib/google_book/book_info.rb, line 25
def get_book(params = {})
  item = @items.detect{|i| i[params.keys.first] == params.values.first} || @items.detect{|i| i["volumeInfo"][params.keys.first] == params.values.first}
  @book = BookItem.new(item: item)
end

Private Instance Methods

show_all_titles_and_subtitles(flag) click to toggle source
# File lib/google_book/book_info.rb, line 31
def show_all_titles_and_subtitles(flag)
  @items[:items].inject do |item|
    @titles << item["volumeInfo"]["title"]
  end
end