Class: AirPlayer::Playlist

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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Playlist

Returns a new instance of Playlist.



7
8
9
10
# File 'lib/airplayer/playlist.rb', line 7

def initialize(options = {})
  @shuffle = options['shuffle'] || false
  @repeat  = options['repeat']  || false
end

Instance Method Details

#add(item) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/airplayer/playlist.rb', line 12

def add(item)
  case type(item)
  when :local_dir
    concat(media_in_local(item))
  when :podcast
    concat(media_in_podcast(item))
  when :url
    push(Media.new(item))
  end
  self
end

#entries(&blk) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/airplayer/playlist.rb', line 24

def entries(&blk)
  loop do
    shuffle! if @shuffle
    send(:each, &blk)
    break unless @repeat
  end
end