Class: SpotifyWebApi::SimplifiedTrackObject
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- SpotifyWebApi::SimplifiedTrackObject
- Defined in:
- lib/spotify_web_api/models/simplified_track_object.rb
Overview
SimplifiedTrackObject Model.
Instance Attribute Summary collapse
-
#artists ⇒ Array[SimplifiedArtistObject]
The artists who performed the track.
-
#available_markets ⇒ Array[String]
A list of the countries in which the track can be played, identified by their [ISO 3166-1 alpha-2](en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code.
-
#disc_number ⇒ Integer
The disc number (usually ‘1` unless the album consists of more than one disc).
-
#duration_ms ⇒ Integer
The track length in milliseconds.
-
#explicit ⇒ TrueClass | FalseClass
Whether or not the track has explicit lyrics ( ‘true` = yes it does; `false` = no it does not OR unknown).
-
#external_urls ⇒ ExternalUrlObject
External URLs for this track.
-
#href ⇒ String
A link to the Web API endpoint providing full details of the track.
-
#id ⇒ String
The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the track.
-
#is_local ⇒ TrueClass | FalseClass
Whether or not the track is from a local file.
-
#is_playable ⇒ TrueClass | FalseClass
Part of the response when [Track Relinking](/documentation/web-api/concepts/track-relinking/) is applied.
-
#linked_from ⇒ LinkedTrackObject
Part of the response when [Track Relinking](/documentation/web-api/concepts/track-relinking/) is applied and is only part of the response if the track linking, in fact, exists.
-
#name ⇒ String
The name of the track.
-
#preview_url ⇒ String
A URL to a 30 second preview (MP3 format) of the track.
-
#restrictions ⇒ TrackRestrictionObject
Included in the response when a content restriction is applied.
-
#track_number ⇒ Integer
The number of the track.
-
#type ⇒ String
The object type: “track”.
-
#uri ⇒ String
The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the track.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(artists = SKIP, available_markets = SKIP, disc_number = SKIP, duration_ms = SKIP, explicit = SKIP, external_urls = SKIP, href = SKIP, id = SKIP, is_playable = SKIP, linked_from = SKIP, restrictions = SKIP, name = SKIP, preview_url = SKIP, track_number = SKIP, type = SKIP, uri = SKIP, is_local = SKIP) ⇒ SimplifiedTrackObject
constructor
A new instance of SimplifiedTrackObject.
Methods inherited from BaseModel
Constructor Details
#initialize(artists = SKIP, available_markets = SKIP, disc_number = SKIP, duration_ms = SKIP, explicit = SKIP, external_urls = SKIP, href = SKIP, id = SKIP, is_playable = SKIP, linked_from = SKIP, restrictions = SKIP, name = SKIP, preview_url = SKIP, track_number = SKIP, type = SKIP, uri = SKIP, is_local = SKIP) ⇒ SimplifiedTrackObject
Returns a new instance of SimplifiedTrackObject.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 148 def initialize(artists = SKIP, available_markets = SKIP, disc_number = SKIP, duration_ms = SKIP, explicit = SKIP, external_urls = SKIP, href = SKIP, id = SKIP, is_playable = SKIP, linked_from = SKIP, restrictions = SKIP, name = SKIP, preview_url = SKIP, track_number = SKIP, type = SKIP, uri = SKIP, is_local = SKIP) @artists = artists unless artists == SKIP @available_markets = available_markets unless available_markets == SKIP @disc_number = disc_number unless disc_number == SKIP @duration_ms = duration_ms unless duration_ms == SKIP @explicit = explicit unless explicit == SKIP @external_urls = external_urls unless external_urls == SKIP @href = href unless href == SKIP @id = id unless id == SKIP @is_playable = is_playable unless is_playable == SKIP @linked_from = linked_from unless linked_from == SKIP @restrictions = restrictions unless restrictions == SKIP @name = name unless name == SKIP @preview_url = preview_url unless preview_url == SKIP @track_number = track_number unless track_number == SKIP @type = type unless type == SKIP @uri = uri unless uri == SKIP @is_local = is_local unless is_local == SKIP end |
Instance Attribute Details
#artists ⇒ Array[SimplifiedArtistObject]
The artists who performed the track. Each artist object includes a link in ‘href` to more detailed information about the artist.
15 16 17 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 15 def artists @artists end |
#available_markets ⇒ Array[String]
A list of the countries in which the track can be played, identified by their [ISO 3166-1 alpha-2](en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code.
21 22 23 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 21 def available_markets @available_markets end |
#disc_number ⇒ Integer
The disc number (usually ‘1` unless the album consists of more than one disc).
26 27 28 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 26 def disc_number @disc_number end |
#duration_ms ⇒ Integer
The track length in milliseconds.
30 31 32 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 30 def duration_ms @duration_ms end |
#explicit ⇒ TrueClass | FalseClass
Whether or not the track has explicit lyrics ( ‘true` = yes it does; `false` = no it does not OR unknown).
35 36 37 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 35 def explicit @explicit end |
#external_urls ⇒ ExternalUrlObject
External URLs for this track.
39 40 41 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 39 def external_urls @external_urls end |
#href ⇒ String
A link to the Web API endpoint providing full details of the track.
43 44 45 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 43 def href @href end |
#id ⇒ String
The [Spotify ID](/documentation/web-api/concepts/spotify-uris-ids) for the track.
48 49 50 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 48 def id @id end |
#is_local ⇒ TrueClass | FalseClass
Whether or not the track is from a local file.
93 94 95 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 93 def is_local @is_local end |
#is_playable ⇒ TrueClass | FalseClass
Part of the response when [Track Relinking](/documentation/web-api/concepts/track-relinking/) is applied. If ‘true`, the track is playable in the given market. Otherwise `false`.
54 55 56 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 54 def is_playable @is_playable end |
#linked_from ⇒ LinkedTrackObject
Part of the response when [Track Relinking](/documentation/web-api/concepts/track-relinking/) is applied and is only part of the response if the track linking, in fact, exists. The requested track has been replaced with a different track. The track in the ‘linked_from` object contains information about the originally requested track.
63 64 65 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 63 def linked_from @linked_from end |
#name ⇒ String
The name of the track.
71 72 73 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 71 def name @name end |
#preview_url ⇒ String
A URL to a 30 second preview (MP3 format) of the track.
75 76 77 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 75 def preview_url @preview_url end |
#restrictions ⇒ TrackRestrictionObject
Included in the response when a content restriction is applied.
67 68 69 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 67 def restrictions @restrictions 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.
80 81 82 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 80 def track_number @track_number end |
#type ⇒ String
The object type: “track”.
84 85 86 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 84 def type @type end |
#uri ⇒ String
The [Spotify URI](/documentation/web-api/concepts/spotify-uris-ids) for the track.
89 90 91 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 89 def uri @uri end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 174 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it artists = nil unless hash['artists'].nil? artists = [] hash['artists'].each do |structure| artists << (SimplifiedArtistObject.from_hash(structure) if structure) end end artists = SKIP unless hash.key?('artists') available_markets = hash.key?('available_markets') ? hash['available_markets'] : SKIP disc_number = hash.key?('disc_number') ? hash['disc_number'] : SKIP duration_ms = hash.key?('duration_ms') ? hash['duration_ms'] : SKIP explicit = hash.key?('explicit') ? hash['explicit'] : SKIP external_urls = ExternalUrlObject.from_hash(hash['external_urls']) if hash['external_urls'] href = hash.key?('href') ? hash['href'] : SKIP id = hash.key?('id') ? hash['id'] : SKIP is_playable = hash.key?('is_playable') ? hash['is_playable'] : SKIP linked_from = LinkedTrackObject.from_hash(hash['linked_from']) if hash['linked_from'] restrictions = TrackRestrictionObject.from_hash(hash['restrictions']) if hash['restrictions'] name = hash.key?('name') ? hash['name'] : SKIP preview_url = hash.key?('preview_url') ? hash['preview_url'] : SKIP track_number = hash.key?('track_number') ? hash['track_number'] : SKIP type = hash.key?('type') ? hash['type'] : SKIP uri = hash.key?('uri') ? hash['uri'] : SKIP is_local = hash.key?('is_local') ? hash['is_local'] : SKIP # Create object from extracted values. SimplifiedTrackObject.new(artists, available_markets, disc_number, duration_ms, explicit, external_urls, href, id, is_playable, linked_from, restrictions, name, preview_url, track_number, type, uri, is_local) end |
.names ⇒ Object
A mapping from model property names to API property names.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 96 def self.names @_hash = {} if @_hash.nil? @_hash['artists'] = 'artists' @_hash['available_markets'] = 'available_markets' @_hash['disc_number'] = 'disc_number' @_hash['duration_ms'] = 'duration_ms' @_hash['explicit'] = 'explicit' @_hash['external_urls'] = 'external_urls' @_hash['href'] = 'href' @_hash['id'] = 'id' @_hash['is_playable'] = 'is_playable' @_hash['linked_from'] = 'linked_from' @_hash['restrictions'] = 'restrictions' @_hash['name'] = 'name' @_hash['preview_url'] = 'preview_url' @_hash['track_number'] = 'track_number' @_hash['type'] = 'type' @_hash['uri'] = 'uri' @_hash['is_local'] = 'is_local' @_hash end |
.nullables ⇒ Object
An array for nullable fields
142 143 144 145 146 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 142 def self.nullables %w[ preview_url ] end |
.optionals ⇒ Object
An array for optional fields
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/spotify_web_api/models/simplified_track_object.rb', line 119 def self.optionals %w[ artists available_markets disc_number duration_ms explicit external_urls href id is_playable linked_from restrictions name preview_url track_number type uri is_local ] end |