Class: Spotify::Models::Track

Inherits:
Object
  • Object
show all
Defined in:
lib/spotify/models/track.rb

Direct Known Subclasses

Full::Track, Simplified::Track

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Track

Sets the arguments to its variables.

Parameters:

  • args (Hash) (defaults to: {})

    the arguments that will be placed on each variable.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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

Instance Attribute Details

#artistsObject (readonly)

Returns the value of attribute artists.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def artists
  @artists
end

#available_marketsObject (readonly)

Returns the value of attribute available_markets.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def available_markets
  @available_markets
end

#disc_numberObject (readonly)

Returns the value of attribute disc_number.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def disc_number
  @disc_number
end

#duration_msObject (readonly)

Returns the value of attribute duration_ms.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def duration_ms
  @duration_ms
end

#explicitObject (readonly)

Returns the value of attribute explicit.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def explicit
  @explicit
end

#external_urlsObject (readonly)

Returns the value of attribute external_urls.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def external_urls
  @external_urls
end

#hrefObject (readonly)

Returns the value of attribute href.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def href
  @href
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def id
  @id
end

#is_playableObject (readonly)

Returns the value of attribute is_playable.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def is_playable
  @is_playable
end

#linked_fromObject (readonly)

Returns the value of attribute linked_from.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def linked_from
  @linked_from
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def name
  @name
end

#preview_urlObject (readonly)

Returns the value of attribute preview_url.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def preview_url
  @preview_url
end

#track_numberObject (readonly)

Returns the value of attribute track_number.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def track_number
  @track_number
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def type
  @type
end

#uriObject (readonly)

Returns the value of attribute uri.



7
8
9
# File 'lib/spotify/models/track.rb', line 7

def uri
  @uri
end