Class: Wishlist

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username:, country:) ⇒ Wishlist

Returns a new instance of Wishlist.



9
10
11
12
# File 'lib/discogs/wishlist/models/wishlist.rb', line 9

def initialize(username:, country:)
  @username = username
  @country = country
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



7
8
9
# File 'lib/discogs/wishlist/models/wishlist.rb', line 7

def country
  @country
end

#usernameObject (readonly)

Returns the value of attribute username.



7
8
9
# File 'lib/discogs/wishlist/models/wishlist.rb', line 7

def username
  @username
end

Instance Method Details

#add_to_wishlist(item) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/discogs/wishlist/models/wishlist.rb', line 14

def add_to_wishlist(item)
  variation = AlbumVariation.new(item)

  album = get_album_from_variation(variation)

  album.add_variation(variation)

  wishlist.sort_by!(&:artist)
end

#each(&block) ⇒ Object



24
25
26
# File 'lib/discogs/wishlist/models/wishlist.rb', line 24

def each(&block)
  wishlist.each(&block)
end