Class: Warg::Context::Playlist
- Inherits:
-
Object
- Object
- Warg::Context::Playlist
- Defined in:
- lib/warg.rb
Instance Method Summary collapse
-
#initialize ⇒ Playlist
constructor
A new instance of Playlist.
- #queue(command) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ Playlist
Returns a new instance of Playlist.
1421 1422 1423 1424 1425 1426 |
# File 'lib/warg.rb', line 1421 def initialize @playing_at = 0 @insert_at = 0 @items = [] @started = false end |
Instance Method Details
#queue(command) ⇒ Object
1440 1441 1442 1443 |
# File 'lib/warg.rb', line 1440 def queue(command) @items.insert(@insert_at, command) @insert_at += 1 end |
#start ⇒ Object
1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 |
# File 'lib/warg.rb', line 1428 def start @started = true @insert_at = 1 until @playing_at >= @items.length @items[@playing_at].run @playing_at += 1 @insert_at = @playing_at + 1 end end |