Class: GoogleBooks::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/book/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ Item

Returns a new instance of Item.



6
7
8
9
10
# File 'lib/book/item.rb', line 6

def initialize(item)
  @item = item
  @volume_info = @item['volumeInfo']
  retrieve_attribute
end

Instance Attribute Details

#authorsObject (readonly)

Returns the value of attribute authors.



4
5
6
# File 'lib/book/item.rb', line 4

def authors
  @authors
end

#authors_arrayObject (readonly)

Returns the value of attribute authors_array.



4
5
6
# File 'lib/book/item.rb', line 4

def authors_array
  @authors_array
end

#average_ratingObject (readonly)

Returns the value of attribute average_rating.



4
5
6
# File 'lib/book/item.rb', line 4

def average_rating
  @average_rating
end

#categoriesObject (readonly)

Returns the value of attribute categories.



4
5
6
# File 'lib/book/item.rb', line 4

def categories
  @categories
end

#descriptionObject (readonly)

Returns the value of attribute description.



4
5
6
# File 'lib/book/item.rb', line 4

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/book/item.rb', line 4

def id
  @id
end

Returns the value of attribute info_link.



4
5
6
# File 'lib/book/item.rb', line 4

def info_link
  @info_link
end

#isbnObject (readonly)

Returns the value of attribute isbn.



4
5
6
# File 'lib/book/item.rb', line 4

def isbn
  @isbn
end

#isbn_10Object (readonly)

Returns the value of attribute isbn_10.



4
5
6
# File 'lib/book/item.rb', line 4

def isbn_10
  @isbn_10
end

#isbn_13Object (readonly)

Returns the value of attribute isbn_13.



4
5
6
# File 'lib/book/item.rb', line 4

def isbn_13
  @isbn_13
end

#kindObject (readonly)

Returns the value of attribute kind.



4
5
6
# File 'lib/book/item.rb', line 4

def kind
  @kind
end

#languageObject (readonly)

Returns the value of attribute language.



4
5
6
# File 'lib/book/item.rb', line 4

def language
  @language
end

#other_identifierObject (readonly)

Returns the value of attribute other_identifier.



4
5
6
# File 'lib/book/item.rb', line 4

def other_identifier
  @other_identifier
end

#page_countObject (readonly)

Returns the value of attribute page_count.



4
5
6
# File 'lib/book/item.rb', line 4

def page_count
  @page_count
end

Returns the value of attribute preview_link.



4
5
6
# File 'lib/book/item.rb', line 4

def preview_link
  @preview_link
end

Returns the value of attribute print_type.



4
5
6
# File 'lib/book/item.rb', line 4

def print_type
  @print_type
end

#published_dateObject (readonly)

Returns the value of attribute published_date.



4
5
6
# File 'lib/book/item.rb', line 4

def published_date
  @published_date
end

#publisherObject (readonly)

Returns the value of attribute publisher.



4
5
6
# File 'lib/book/item.rb', line 4

def publisher
  @publisher
end

#ratings_countObject (readonly)

Returns the value of attribute ratings_count.



4
5
6
# File 'lib/book/item.rb', line 4

def ratings_count
  @ratings_count
end

#sale_infoObject (readonly)

Returns the value of attribute sale_info.



4
5
6
# File 'lib/book/item.rb', line 4

def sale_info
  @sale_info
end

#titleObject (readonly)

Returns the value of attribute title.



4
5
6
# File 'lib/book/item.rb', line 4

def title
  @title
end

#titles_arrayObject (readonly)

Returns the value of attribute titles_array.



4
5
6
# File 'lib/book/item.rb', line 4

def titles_array
  @titles_array
end

Instance Method Details

Enables image_link attribute to be customized via passing optional zoom and edge arguments as a hash



14
15
16
17
18
# File 'lib/book/item.rb', line 14

def image_link(opts = {})
  opts[:zoom] ||= 1
  opts[:curl] ||= false
  @volume_info['imageLinks']['thumbnail'].gsub('zoom=1', "zoom=#{opts[:zoom]}").gsub('&edge=curl', "&edge=#{opts[:curl] ? 'curl' : 'none'}") rescue nil
end