Class: Spotify::SDK::Item

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

#albumSpotify::SDK::Album

Get the album for this item.

Examples:

@sdk.connect.playback.item.album

14
15
16
# File 'lib/spotify/sdk/item.rb', line 14

def album
  Spotify::SDK::Album.new(super, parent)
end

#artistSpotify::SDK::Artist

Get the primary artist/creator for this item.

Examples:

@sdk.connect.playback.item.artist

40
41
42
# File 'lib/spotify/sdk/item.rb', line 40

def artist
  artists.first
end

#artistsArray

Get the artists/creators for this item.

Examples:

@sdk.connect.playback.item.artists

26
27
28
29
30
# File 'lib/spotify/sdk/item.rb', line 26

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

#durationInteger

Get the duration. Alias to self.duration_ms

Examples:

@sdk.connect.playback.item.duration # => 10331

53
# File 'lib/spotify/sdk/item.rb', line 53

alias_attribute :duration, :duration_ms

#explicit?TrueClass, FalseClass

Is this track explicit? Alias to self.explicit

Examples:

@sdk.connect.playback.item.explicit? # => true

64
# File 'lib/spotify/sdk/item.rb', line 64

alias_attribute :explicit?, :explicit

#isrcString

Get the ISRC for this track.

Examples:

@sdk.connect.playback.item.isrc # => "USUM00000000"

131
# File 'lib/spotify/sdk/item.rb', line 131

alias_attribute :isrc, "external_ids.isrc"

#local?TrueClass, FalseClass

Is this a local track, not a Spotify track? Alias to self.is_local

Examples:

@sdk.connect.playback.item.local? # => false

75
# File 'lib/spotify/sdk/item.rb', line 75

alias_attribute :local?, :is_local

#playable?TrueClass, FalseClass

Is this a playable track? Alias to self.is_playable

Examples:

@sdk.connect.playback.item.playable? # => false

86
# File 'lib/spotify/sdk/item.rb', line 86

alias_attribute :playable?, :is_playable

#spotify_uriString

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

Examples:

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

110
# File 'lib/spotify/sdk/item.rb', line 110

alias_attribute :spotify_uri, :uri

#spotify_urlString

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

Examples:

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

121
# File 'lib/spotify/sdk/item.rb', line 121

alias_attribute :spotify_url, "external_urls.spotify"

#track?TrueClass, FalseClass

Is this a track? Alias to self.type == “track”

Examples:

@sdk.connect.playback.item.track? # => true

97
98
99
# File 'lib/spotify/sdk/item.rb', line 97

def track?
  type == "track"
end