class Album
Attributes
id[R]
Public Class Methods
new(id)
click to toggle source
# File lib/discogs/wishlist/models/album.rb, line 4 def initialize(id) @id = id end
Public Instance Methods
add_variation(variation)
click to toggle source
# File lib/discogs/wishlist/models/album.rb, line 8 def add_variation(variation) variations << variation end
artist()
click to toggle source
# File lib/discogs/wishlist/models/album.rb, line 16 def artist @artist ||= variations.first&.artist end
items_for_sale_count()
click to toggle source
# File lib/discogs/wishlist/models/album.rb, line 40 def items_for_sale_count @items_for_sale_count ||= saleable_variations.sum(&:items_for_sale_count) end
lowest_price()
click to toggle source
# File lib/discogs/wishlist/models/album.rb, line 20 def lowest_price @lowest_price ||= begin return nil unless items_for_sale_count.positive? saleable_variations.map(&:lowest_price).min_by { |price| price[:price] } end end
lowest_price_cost()
click to toggle source
# File lib/discogs/wishlist/models/album.rb, line 28 def lowest_price_cost return nil if lowest_price.nil? @lowest_price_cost ||= lowest_price[:price].format end
lowest_price_shipping()
click to toggle source
# File lib/discogs/wishlist/models/album.rb, line 34 def lowest_price_shipping return nil if lowest_price.nil? @lowest_price_shipping ||= lowest_price[:shipping].format end
saleable_variations()
click to toggle source
# File lib/discogs/wishlist/models/album.rb, line 44 def saleable_variations @saleable_variations ||= variations.select(&:saleable?) end
title()
click to toggle source
# File lib/discogs/wishlist/models/album.rb, line 12 def title @title ||= variations.first&.title end
variations()
click to toggle source
# File lib/discogs/wishlist/models/album.rb, line 48 def variations @variations ||= [] end