Class: Album
- Inherits:
-
Object
- Object
- Album
- Defined in:
- lib/track.rb
Instance Attribute Summary collapse
-
#album ⇒ Object
Returns the value of attribute album.
-
#amazon_average_rating ⇒ Object
Returns the value of attribute amazon_average_rating.
-
#amazon_price ⇒ Object
Returns the value of attribute amazon_price.
-
#amazon_sales_rank ⇒ Object
Returns the value of attribute amazon_sales_rank.
-
#amazon_total_reviews ⇒ Object
Returns the value of attribute amazon_total_reviews.
-
#artist ⇒ Object
Returns the value of attribute artist.
-
#tracks ⇒ Object
Returns the value of attribute tracks.
Instance Method Summary collapse
- #add_track(track) ⇒ Object
- #get_amazon_info ⇒ Object
-
#initialize(album, artist, track) ⇒ Album
constructor
A new instance of Album.
Constructor Details
#initialize(album, artist, track) ⇒ Album
Returns a new instance of Album.
10 11 12 13 14 15 |
# File 'lib/track.rb', line 10 def initialize(album, artist, track) @album = album @artist = artist @tracks = [] add_track(track) end |
Instance Attribute Details
#album ⇒ Object
Returns the value of attribute album.
8 9 10 |
# File 'lib/track.rb', line 8 def album @album end |
#amazon_average_rating ⇒ Object
Returns the value of attribute amazon_average_rating.
8 9 10 |
# File 'lib/track.rb', line 8 def @amazon_average_rating end |
#amazon_price ⇒ Object
Returns the value of attribute amazon_price.
8 9 10 |
# File 'lib/track.rb', line 8 def amazon_price @amazon_price end |
#amazon_sales_rank ⇒ Object
Returns the value of attribute amazon_sales_rank.
8 9 10 |
# File 'lib/track.rb', line 8 def amazon_sales_rank @amazon_sales_rank end |
#amazon_total_reviews ⇒ Object
Returns the value of attribute amazon_total_reviews.
8 9 10 |
# File 'lib/track.rb', line 8 def amazon_total_reviews @amazon_total_reviews end |
#artist ⇒ Object
Returns the value of attribute artist.
8 9 10 |
# File 'lib/track.rb', line 8 def artist @artist end |
#tracks ⇒ Object
Returns the value of attribute tracks.
8 9 10 |
# File 'lib/track.rb', line 8 def tracks @tracks end |
Instance Method Details
#add_track(track) ⇒ Object
17 18 19 |
# File 'lib/track.rb', line 17 def add_track(track) @tracks << track end |
#get_amazon_info ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/track.rb', line 21 def get_amazon_info request = Request.new(KEY_ID) unless @artist == nil || @album == nil then is = ItemSearch.new('Music', {'Artist' => @artist, 'Title' => @album, 'MerchantId' => 'Amazon'}) rg = ResponseGroup.new('Large') begin response = request.search(is, rg) items = response.item_search_response.items.item @amazon_average_rating = items[0]..to_s @amazon_total_reviews = items[0].total_reviews.to_s @amazon_price = items[0].item_attributes.list_price.amount.to_s @amazon_sales_rank = items[0].sales_rank.to_s rescue Amazon::AWS::Error::NoExactMatches # do nothing? end end end |