Class: Spotify::SDK::Image

Inherits:
Model
  • Object
show all
Defined in:
lib/spotify/sdk/image.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

#idString

Get the ID of the image.

Examples:

artist = @sdk.connect.playback.artist
artist.images[0].id # => "941223d904f006c4d998598272d43d94"

Returns:

  • (String)

    image_id The image ID generated from Spotify.



15
16
17
# File 'lib/spotify/sdk/image.rb', line 15

def id
  url.match(/[a-z0-9]+$/i)[0]
end

#spotify_uriString

Get the mobile-related link for the image. Designed for offline mobile apps.

Examples:

artist = @sdk.connect.playback.artist
artist.images[0].spotify_uri # => "spoitfy:image:..."

Returns:

  • (String)

    spotify_uri The mobile-embeddable image for the item.



28
29
30
# File 'lib/spotify/sdk/image.rb', line 28

def spotify_uri
  "spotify:image:%s" % id
end

#spotify_urlString

Get the HTTP link for the image. Designed for web apps.

Examples:

artist = @sdk.connect.playback.artist
artist.images[0].spotify_url # => "https://i.scdn.co/image/..."

Returns:

  • (String)

    spotify_url The web-embeddable HTTP image for the item.



41
# File 'lib/spotify/sdk/image.rb', line 41

alias_attribute :spotify_url, :url