Class: RSpotify::Player

Inherits:
Object
  • Object
show all
Defined in:
lib/shellify/rspotify_patch.rb

Instance Method Summary collapse

Instance Method Details

#currently_playingObject



16
17
18
19
20
21
22
23
# File 'lib/shellify/rspotify_patch.rb', line 16

def currently_playing
  url = 'me/player/currently-playing'
  response = User.oauth_get(@user.id, url)
  return response if RSpotify.raw_response

  type_class = RSpotify.const_get(response['currently_playing_type'].capitalize)
  type_class.new response['item'] unless response['item'].nil?
end

#next_upObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/shellify/rspotify_patch.rb', line 5

def next_up
  url = 'me/player/queue'
  response = User.oauth_get(@user.id, url)
  return response if RSpotify.raw_response

  response['queue'].map do |item|
    type_class = RSpotify.const_get(item['type'].capitalize)
    type_class.new item
  end
end