Class: Postrocktues::Playlist
- Inherits:
-
Object
- Object
- Postrocktues::Playlist
- Defined in:
- lib/postrocktues/playlist.rb
Instance Attribute Summary collapse
-
#spotify ⇒ Object
readonly
Returns the value of attribute spotify.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #add(tracks, place = 0) ⇒ Object (also: #<<)
- #clear! ⇒ Object
-
#initialize(opts = {}) ⇒ Playlist
constructor
A new instance of Playlist.
- #size ⇒ Object
- #upload ⇒ Object
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
#spotify ⇒ Object (readonly)
Returns the value of attribute spotify.
6 7 8 |
# File 'lib/postrocktues/playlist.rb', line 6 def spotify @spotify end |
#uri ⇒ Object (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 |
#size ⇒ Object
23 24 25 |
# File 'lib/postrocktues/playlist.rb', line 23 def size playlist.size end |
#upload ⇒ Object
27 28 29 |
# File 'lib/postrocktues/playlist.rb', line 27 def upload playlist.upload end |