Class: Airplay::Player::Playlist

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable
Defined in:
lib/airplay/player/playlist.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Playlist

Returns a new instance of Playlist.



14
15
16
17
18
# File 'lib/airplay/player/playlist.rb', line 14

def initialize(name)
  @name = name
  @items = []
  @position = 0
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/airplay/player/playlist.rb', line 10

def name
  @name
end

Instance Method Details

#<<(file_or_url) ⇒ Object



24
25
26
# File 'lib/airplay/player/playlist.rb', line 24

def <<(file_or_url)
  @items << Media.new(file_or_url)
end

#nextObject



31
32
33
34
35
36
37
# File 'lib/airplay/player/playlist.rb', line 31

def next
  return nil if !next?

  item = @items[@position]
  @position += 1
  item
end

#next?Boolean

Returns:

  • (Boolean)


28
# File 'lib/airplay/player/playlist.rb', line 28

def next?;     @position + 1 <= @items.size end

#previousObject



39
40
41
42
43
44
# File 'lib/airplay/player/playlist.rb', line 39

def previous
  return nil if !previous?

  @position -= 1
  @items[@position]
end

#previous?Boolean

Returns:

  • (Boolean)


29
# File 'lib/airplay/player/playlist.rb', line 29

def previous?; @position - 1 >= 0 end

#to_aryObject



20
21
22
# File 'lib/airplay/player/playlist.rb', line 20

def to_ary
  @items
end