Method: RSpotify::Album#initialize

Defined in:
lib/rspotify/album.rb

#initialize(options = {}) ⇒ Album

Returns a new instance of Album.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/rspotify/album.rb', line 74

def initialize(options = {})
  @album_type             = options['album_type']
  @available_markets      = options['available_markets']
  @copyrights             = options['copyrights']
  @external_ids           = options['external_ids']
  @genres                 = options['genres']
  @images                 = options['images']
  @label                  = options['label']
  @name                   = options['name']
  @popularity             = options['popularity']
  @release_date           = options['release_date']
  @release_date_precision = options['release_date_precision']

  @artists = if options['artists']
    options['artists'].map { |a| Artist.new a }
  end

  @tracks_cache, @total_tracks = if options['tracks'] && options['tracks']['items']
    [
      options['tracks']['items'].map { |i| Track.new i },
      options['tracks']['total']
    ]
  end

  super(options)
end