class Spotify::Models::Track

Attributes

artists[R]
available_markets[R]
disc_number[R]
duration_ms[R]
explicit[R]
external_urls[R]
href[R]
id[R]
is_playable[R]
linked_from[R]
name[R]
preview_url[R]
track_number[R]
type[R]
uri[R]

Public Class Methods

new(args = {}) click to toggle source

Sets the arguments to its variables.

@param [Hash] args the arguments that will be placed on each variable.

@return [Track] a track object.

# File lib/spotify/models/track.rb, line 18
def initialize(args = {})
  args = Hash(args).with_indifferent_access

  # Arrays
  artist  = Spotify::Models::Simplified::Artist
  artists = Array(args[:artists]).map { |a| artist.new(a) }

  # Objects
  external_urls = Spotify::Models::ExternalURL.new(args[:external_urls])
  track_link    = Spotify::Models::TrackLink.new(args[:linked_from])

  @artists           = artists
  @available_markets = args[:available_markets]
  @disc_number       = args[:disc_number]
  @duration_ms       = args[:duration_ms]
  @explicit          = args[:explicit]
  @external_urls     = external_urls
  @href              = args[:href]
  @id                = args[:id]
  @is_playable       = args[:is_playable]
  @linked_from       = track_link
  @name              = args[:name]
  @preview_url       = args[:preview_url]
  @track_number      = args[:track_number]
  @type              = args[:type]
  @uri               = args[:uri]
end