Class: Postrocktues::Playlist

Inherits:
Object
  • Object
show all
Defined in:
lib/postrocktues/playlist.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Playlist

Returns a new instance of Playlist.



8
9
10
11
12
# File 'lib/postrocktues/playlist.rb', line 8

def initialize opts = {}
  config = opts.fetch(:config) { config_fallback }
  @uri = opts.fetch(:uri) { config.playlist }
  @spotify = opts.fetch(:spotify) { spotify_fallback }
end

Instance Attribute Details

#spotifyObject (readonly)

Returns the value of attribute spotify.



6
7
8
# File 'lib/postrocktues/playlist.rb', line 6

def spotify
  @spotify
end

#uriObject (readonly)

Returns the value of attribute uri.



6
7
8
# File 'lib/postrocktues/playlist.rb', line 6

def uri
  @uri
end

Instance Method Details

#add(tracks, place = 0) ⇒ Object Also known as: <<



14
15
16
# File 'lib/postrocktues/playlist.rb', line 14

def add tracks, place = 0
  tracks.reverse.map { |t| playlist.insert place, spotify.track(t.uri) }
end

#clear!Object



19
20
21
# File 'lib/postrocktues/playlist.rb', line 19

def clear!
  playlist.size.times { playlist.remove 0 }
end

#sizeObject



23
24
25
# File 'lib/postrocktues/playlist.rb', line 23

def size
  playlist.size
end

#uploadObject



27
28
29
# File 'lib/postrocktues/playlist.rb', line 27

def upload
  playlist.upload
end