Class: AlbumVariation

Inherits:
Object
  • Object
show all
Defined in:
lib/discogs/wishlist/models/album_variation.rb

Instance Method Summary collapse

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

#artistObject



42
43
44
# File 'lib/discogs/wishlist/models/album_variation.rb', line 42

def artist
  variation.basic_information.artists.map(&:name)&.join(", ")
end

#idObject



18
19
20
# File 'lib/discogs/wishlist/models/album_variation.rb', line 18

def id
  variation.id
end

#items_for_sale_countObject



30
31
32
# File 'lib/discogs/wishlist/models/album_variation.rb', line 30

def items_for_sale_count
  @items_for_sale.length
end

#lowest_priceObject



34
35
36
# File 'lib/discogs/wishlist/models/album_variation.rb', line 34

def lowest_price
  @lowest_price ||= @items_for_sale.first
end

#master_idObject



26
27
28
# File 'lib/discogs/wishlist/models/album_variation.rb', line 26

def master_id
  variation.basic_information.master_id
end

#saleable?Boolean

Returns:

  • (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

#titleObject



38
39
40
# File 'lib/discogs/wishlist/models/album_variation.rb', line 38

def title
  variation.basic_information.title
end

#urlObject



22
23
24
# File 'lib/discogs/wishlist/models/album_variation.rb', line 22

def url
  variation.basic_information.resource_url
end