Class: RSpotify::Track
Instance Attribute Summary collapse
-
#album ⇒ Album
The album on which the track appears.
-
#artists ⇒ Array<Artist>
The artists who performed the track.
-
#available_markets ⇒ Array<String>
The markets in which the track can be played.
-
#disc_number ⇒ Integer
The disc number.
-
#duration_ms ⇒ Integer
The track length in milliseconds.
-
#explicit ⇒ Boolean
Whether or not the track has explicit lyrics.
-
#external_ids ⇒ Hash
Known external IDs for the track.
-
#name ⇒ String
The name of the track.
-
#popularity ⇒ Integer
The popularity of the track.
-
#preview_url ⇒ String
A link to a 30 second preview (MP3 format) of the track.
-
#track_number ⇒ Integer
The number of the track.
Attributes inherited from Base
#external_urls, #href, #id, #type, #uri
Class Method Summary collapse
-
.find(ids) ⇒ Track+
Returns Track object(s) with id(s) provided.
-
.search(query, limit: 20, offset: 0) ⇒ Array<Track>
Returns array of Track objects matching the query, ordered by popularity.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Track
constructor
A new instance of Track.
Methods inherited from Base
#complete!, #method_missing, #respond_to?
Constructor Details
#initialize(options = {}) ⇒ Track
Returns a new instance of Track.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/rspotify/track.rb', line 53 def initialize( = {}) @available_markets = ['available_markets'] @disc_number = ['disc_number'] @duration_ms = ['duration_ms'] @explicit = ['explicit'] @external_ids = ['external_ids'] @name = ['name'] @popularity = ['popularity'] @preview_url = ['preview_url'] @track_number = ['track_number'] @album = if ['album'] Album.new ['album'] end @artists = if ['artists'] ['artists'].map { |a| Artist.new a } end super() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RSpotify::Base
Instance Attribute Details
#album ⇒ Album
The album on which the track appears
14 15 16 |
# File 'lib/rspotify/track.rb', line 14 def album @album end |
#artists ⇒ Array<Artist>
The artists who performed the track
14 15 16 |
# File 'lib/rspotify/track.rb', line 14 def artists @artists end |
#available_markets ⇒ Array<String>
The markets in which the track can be played. See ISO 3166-1 alpha-2 country codes
14 15 16 |
# File 'lib/rspotify/track.rb', line 14 def available_markets @available_markets end |
#disc_number ⇒ Integer
The disc number. Usually 1 unless the album consists of more than one disc
14 15 16 |
# File 'lib/rspotify/track.rb', line 14 def disc_number @disc_number end |
#duration_ms ⇒ Integer
The track length in milliseconds
14 15 16 |
# File 'lib/rspotify/track.rb', line 14 def duration_ms @duration_ms end |
#explicit ⇒ Boolean
Whether or not the track has explicit lyrics. true = yes it does; false = no it does not OR unknown
14 15 16 |
# File 'lib/rspotify/track.rb', line 14 def explicit @explicit end |
#external_ids ⇒ Hash
Known external IDs for the track
14 15 16 |
# File 'lib/rspotify/track.rb', line 14 def external_ids @external_ids end |
#name ⇒ String
The name of the track
14 15 16 |
# File 'lib/rspotify/track.rb', line 14 def name @name end |
#popularity ⇒ Integer
The popularity of the track. The value will be between 0 and 100, with 100 being the most popular
14 15 16 |
# File 'lib/rspotify/track.rb', line 14 def popularity @popularity end |
#preview_url ⇒ String
A link to a 30 second preview (MP3 format) of the track
14 15 16 |
# File 'lib/rspotify/track.rb', line 14 def preview_url @preview_url end |
#track_number ⇒ Integer
The number of the track. If an album has several discs, the track number is the number on the specified disc
14 15 16 |
# File 'lib/rspotify/track.rb', line 14 def track_number @track_number end |
Class Method Details
.find(ids) ⇒ Track+
Returns Track object(s) with id(s) provided
30 31 32 |
# File 'lib/rspotify/track.rb', line 30 def self.find(ids) super(ids, 'track') end |
.search(query, limit: 20, offset: 0) ⇒ Array<Track>
Returns array of Track objects matching the query, ordered by popularity
49 50 51 |
# File 'lib/rspotify/track.rb', line 49 def self.search(query, limit: 20, offset: 0) super(query, 'track', limit: limit, offset: offset) end |