Class: SpotifyWebApi::PlaylistTrackObject
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- SpotifyWebApi::PlaylistTrackObject
- Defined in:
- lib/spotify_web_api/models/playlist_track_object.rb
Overview
PlaylistTrackObject Model.
Instance Attribute Summary collapse
-
#added_at ⇒ DateTime
The date and time the track or episode was added.
-
#added_by ⇒ PlaylistUserObject
The Spotify user who added the track or episode.
-
#is_local ⇒ TrueClass | FalseClass
Whether this track or episode is a [local file](/documentation/web-api/concepts/playlists/#local-files) or not.
-
#track ⇒ Object
Information about the track or episode.
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(added_at = SKIP, added_by = SKIP, is_local = SKIP, track = SKIP) ⇒ PlaylistTrackObject
constructor
A new instance of PlaylistTrackObject.
- #to_custom_added_at ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(added_at = SKIP, added_by = SKIP, is_local = SKIP, track = SKIP) ⇒ PlaylistTrackObject
Returns a new instance of PlaylistTrackObject.
57 58 59 60 61 62 63 |
# File 'lib/spotify_web_api/models/playlist_track_object.rb', line 57 def initialize(added_at = SKIP, added_by = SKIP, is_local = SKIP, track = SKIP) @added_at = added_at unless added_at == SKIP @added_by = added_by unless added_by == SKIP @is_local = is_local unless is_local == SKIP @track = track unless track == SKIP end |
Instance Attribute Details
#added_at ⇒ DateTime
The date and time the track or episode was added. _Note: some very old playlists may return ‘null` in this field._
16 17 18 |
# File 'lib/spotify_web_api/models/playlist_track_object.rb', line 16 def added_at @added_at end |
#added_by ⇒ PlaylistUserObject
The Spotify user who added the track or episode. _Note: some very old playlists may return ‘null` in this field._
21 22 23 |
# File 'lib/spotify_web_api/models/playlist_track_object.rb', line 21 def added_by @added_by end |
#is_local ⇒ TrueClass | FalseClass
Whether this track or episode is a [local file](/documentation/web-api/concepts/playlists/#local-files) or not.
26 27 28 |
# File 'lib/spotify_web_api/models/playlist_track_object.rb', line 26 def is_local @is_local end |
#track ⇒ Object
Information about the track or episode.
30 31 32 |
# File 'lib/spotify_web_api/models/playlist_track_object.rb', line 30 def track @track end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/spotify_web_api/models/playlist_track_object.rb', line 66 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. added_at = if hash.key?('added_at') (DateTimeHelper.from_rfc3339(hash['added_at']) if hash['added_at']) else SKIP end added_by = PlaylistUserObject.from_hash(hash['added_by']) if hash['added_by'] is_local = hash.key?('is_local') ? hash['is_local'] : SKIP track = hash.key?('track') ? hash['track'] : SKIP # Create object from extracted values. PlaylistTrackObject.new(added_at, added_by, is_local, track) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 |
# File 'lib/spotify_web_api/models/playlist_track_object.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['added_at'] = 'added_at' @_hash['added_by'] = 'added_by' @_hash['is_local'] = 'is_local' @_hash['track'] = 'track' @_hash end |
.nullables ⇒ Object
An array for nullable fields
53 54 55 |
# File 'lib/spotify_web_api/models/playlist_track_object.rb', line 53 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
43 44 45 46 47 48 49 50 |
# File 'lib/spotify_web_api/models/playlist_track_object.rb', line 43 def self.optionals %w[ added_at added_by is_local track ] end |
Instance Method Details
#to_custom_added_at ⇒ Object
86 87 88 |
# File 'lib/spotify_web_api/models/playlist_track_object.rb', line 86 def to_custom_added_at DateTimeHelper.to_rfc3339(added_at) end |