Class: SpotifyWebApi::CurrentlyPlayingObject
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- SpotifyWebApi::CurrentlyPlayingObject
- Defined in:
- lib/spotify_web_api/models/currently_playing_object.rb
Overview
CurrentlyPlayingObject Model.
Instance Attribute Summary collapse
-
#actions ⇒ DisallowsObject
Allows to update the user interface based on which playback actions are available within the current context.
-
#context ⇒ ContextObject
A Context Object.
-
#currently_playing_type ⇒ String
The object type of the currently playing item.
-
#is_playing ⇒ TrueClass | FalseClass
If something is currently playing, return
true. -
#item ⇒ Object
The currently playing track or episode.
-
#progress_ms ⇒ Integer
Progress into the currently playing track or episode.
-
#timestamp ⇒ Integer
Unix Millisecond Timestamp when data was fetched.
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(context = SKIP, timestamp = SKIP, progress_ms = SKIP, is_playing = SKIP, item = SKIP, currently_playing_type = SKIP, actions = SKIP) ⇒ CurrentlyPlayingObject
constructor
A new instance of CurrentlyPlayingObject.
Methods inherited from BaseModel
Constructor Details
#initialize(context = SKIP, timestamp = SKIP, progress_ms = SKIP, is_playing = SKIP, item = SKIP, currently_playing_type = SKIP, actions = SKIP) ⇒ CurrentlyPlayingObject
Returns a new instance of CurrentlyPlayingObject.
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/spotify_web_api/models/currently_playing_object.rb', line 73 def initialize(context = SKIP, = SKIP, progress_ms = SKIP, = SKIP, item = SKIP, = SKIP, actions = SKIP) @context = context unless context == SKIP @timestamp = unless == SKIP @progress_ms = progress_ms unless progress_ms == SKIP @is_playing = unless == SKIP @item = item unless item == SKIP @currently_playing_type = unless == SKIP @actions = actions unless actions == SKIP end |
Instance Attribute Details
#actions ⇒ DisallowsObject
Allows to update the user interface based on which playback actions are available within the current context.
40 41 42 |
# File 'lib/spotify_web_api/models/currently_playing_object.rb', line 40 def actions @actions end |
#context ⇒ ContextObject
A Context Object. Can be null.
14 15 16 |
# File 'lib/spotify_web_api/models/currently_playing_object.rb', line 14 def context @context end |
#currently_playing_type ⇒ String
The object type of the currently playing item. Can be one of track, episode, ad or unknown.
35 36 37 |
# File 'lib/spotify_web_api/models/currently_playing_object.rb', line 35 def @currently_playing_type end |
#is_playing ⇒ TrueClass | FalseClass
If something is currently playing, return true.
26 27 28 |
# File 'lib/spotify_web_api/models/currently_playing_object.rb', line 26 def @is_playing end |
#item ⇒ Object
The currently playing track or episode. Can be null.
30 31 32 |
# File 'lib/spotify_web_api/models/currently_playing_object.rb', line 30 def item @item end |
#progress_ms ⇒ Integer
Progress into the currently playing track or episode. Can be null.
22 23 24 |
# File 'lib/spotify_web_api/models/currently_playing_object.rb', line 22 def progress_ms @progress_ms end |
#timestamp ⇒ Integer
Unix Millisecond Timestamp when data was fetched
18 19 20 |
# File 'lib/spotify_web_api/models/currently_playing_object.rb', line 18 def @timestamp end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/spotify_web_api/models/currently_playing_object.rb', line 86 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. context = ContextObject.from_hash(hash['context']) if hash['context'] = hash.key?('timestamp') ? hash['timestamp'] : SKIP progress_ms = hash.key?('progress_ms') ? hash['progress_ms'] : SKIP = hash.key?('is_playing') ? hash['is_playing'] : SKIP item = hash.key?('item') ? hash['item'] : SKIP = hash.key?('currently_playing_type') ? hash['currently_playing_type'] : SKIP actions = DisallowsObject.from_hash(hash['actions']) if hash['actions'] # Create object from extracted values. CurrentlyPlayingObject.new(context, , progress_ms, , item, , actions) end |
.names ⇒ Object
A mapping from model property names to API property names.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/spotify_web_api/models/currently_playing_object.rb', line 43 def self.names @_hash = {} if @_hash.nil? @_hash['context'] = 'context' @_hash['timestamp'] = 'timestamp' @_hash['progress_ms'] = 'progress_ms' @_hash['is_playing'] = 'is_playing' @_hash['item'] = 'item' @_hash['currently_playing_type'] = 'currently_playing_type' @_hash['actions'] = 'actions' @_hash end |
.nullables ⇒ Object
An array for nullable fields
69 70 71 |
# File 'lib/spotify_web_api/models/currently_playing_object.rb', line 69 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/spotify_web_api/models/currently_playing_object.rb', line 56 def self.optionals %w[ context timestamp progress_ms is_playing item currently_playing_type actions ] end |