Class: Warg::Context::Playlist

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

Instance Method Summary collapse

Constructor Details

#initializePlaylist

Returns a new instance of Playlist.



1420
1421
1422
1423
1424
1425
# File 'lib/warg.rb', line 1420

def initialize
  @playing_at = 0
  @insert_at = 0
  @items = []
  @started = false
end

Instance Method Details

#queue(command) ⇒ Object



1439
1440
1441
1442
# File 'lib/warg.rb', line 1439

def queue(command)
  @items.insert(@insert_at, command)
  @insert_at += 1
end

#startObject



1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
# File 'lib/warg.rb', line 1427

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