Class: AlbumVariation
- Inherits:
-
Object
- Object
- AlbumVariation
- Defined in:
- lib/discogs/wishlist/models/album_variation.rb
Instance Method Summary collapse
- #add_items_for_sale(for_sale_items) ⇒ Object
- #artist ⇒ Object
- #id ⇒ Object
-
#initialize(variation) ⇒ AlbumVariation
constructor
A new instance of AlbumVariation.
- #items_for_sale_count ⇒ Object
- #lowest_price ⇒ Object
- #master_id ⇒ Object
- #saleable? ⇒ Boolean
- #title ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(variation) ⇒ AlbumVariation
Returns a new instance of AlbumVariation.
2 3 4 |
# File 'lib/discogs/wishlist/models/album_variation.rb', line 2 def initialize(variation) @variation = variation end |
Instance Method Details
#add_items_for_sale(for_sale_items) ⇒ Object
12 13 14 15 16 |
# File 'lib/discogs/wishlist/models/album_variation.rb', line 12 def add_items_for_sale(for_sale_items) new_items = items_for_sale.dup + for_sale_items.compact.sort_by { |info| info[:price] } @items_for_sale = new_items end |
#artist ⇒ Object
42 43 44 |
# File 'lib/discogs/wishlist/models/album_variation.rb', line 42 def artist variation.basic_information.artists.map(&:name)&.join(", ") end |
#id ⇒ Object
18 19 20 |
# File 'lib/discogs/wishlist/models/album_variation.rb', line 18 def id variation.id end |
#items_for_sale_count ⇒ Object
30 31 32 |
# File 'lib/discogs/wishlist/models/album_variation.rb', line 30 def items_for_sale_count @items_for_sale.length end |
#lowest_price ⇒ Object
34 35 36 |
# File 'lib/discogs/wishlist/models/album_variation.rb', line 34 def lowest_price @lowest_price ||= @items_for_sale.first end |
#master_id ⇒ Object
26 27 28 |
# File 'lib/discogs/wishlist/models/album_variation.rb', line 26 def master_id variation.basic_information.master_id end |
#saleable? ⇒ Boolean
6 7 8 9 10 |
# File 'lib/discogs/wishlist/models/album_variation.rb', line 6 def saleable? return false unless @items_for_sale @items_for_sale.length.positive? end |
#title ⇒ Object
38 39 40 |
# File 'lib/discogs/wishlist/models/album_variation.rb', line 38 def title variation.basic_information.title end |
#url ⇒ Object
22 23 24 |
# File 'lib/discogs/wishlist/models/album_variation.rb', line 22 def url variation.basic_information.resource_url end |