Class: Spotify::SDK::Album

Inherits:
Model
  • Object
show all
Defined in:
lib/spotify/sdk/album.rb

Instance Attribute Summary

Attributes inherited from Model

#parent

Instance Method Summary collapse

Methods inherited from Model

alias_attribute, hash_selector, #initialize, #to_h, #to_json

Constructor Details

This class inherits a constructor from Spotify::SDK::Model

Instance Method Details

#album?TrueClass, FalseClass

Is this an album? Note: This is mostly to support other types of albums in the future.

Examples:

album = @sdk.connect.playback.item.album
album.album?

Returns:

  • (TrueClass, FalseClass)

    is_album Returns true if type is an album.



16
17
18
# File 'lib/spotify/sdk/album.rb', line 16

def album?
  type == "album"
end

#artistSpotify::SDK::Artist

Get the primary artist/creator for this album.

Examples:

@sdk.connect.playback.item.album.artist

Returns:



57
58
59
# File 'lib/spotify/sdk/album.rb', line 57

def artist
  artists.first
end

#artistsArray

Get the artists/creators for this album.

Examples:

@sdk.connect.playback.item.album.artists

Returns:

  • (Array)

    artists A list of artists, wrapped in Spotify::SDK::Artist



43
44
45
46
47
# File 'lib/spotify/sdk/album.rb', line 43

def artists
  super.map do |artist|
    Spotify::SDK::Artist.new(artist, parent)
  end
end

#imagesArray

Display the album’s images.

Examples:

album = @sdk.connect.playback.item.album
album.images[0] # => [#<Spotify::SDK::Image>, #<Spotify::SDK::Image>, ...]

Returns:

  • (Array)

    album_images Contains a list of images, wrapped in Spotify::SDK::Image



29
30
31
32
33
# File 'lib/spotify/sdk/album.rb', line 29

def images
  super.map do |image|
    Spotify::SDK::Image.new(image, parent)
  end
end

#spotify_uriString

Get the Spotify URI for this album. Alias to self.uri

Examples:

@sdk.connect.playback.item.album.spotify_uri # => "spotify:track:..."

Returns:

  • (String)

    spotify_uri The direct URI to this Spotify resource.



70
# File 'lib/spotify/sdk/album.rb', line 70

alias_attribute :spotify_uri, :uri

#spotify_urlString

Get the Spotify HTTP URL for this album. Alias to self.external_urls

Examples:

@sdk.connect.playback.item.album.spotify_url # => "https://open.spotify.com/..."

Returns:

  • (String)

    spotify_url The direct HTTP URL to this Spotify resource.



81
# File 'lib/spotify/sdk/album.rb', line 81

alias_attribute :spotify_url, "external_urls.spotify"