Class: Airplay::Player::Playlist
- Inherits:
-
Object
- Object
- Airplay::Player::Playlist
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/airplay/player/playlist.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #<<(file_or_url) ⇒ Object
-
#initialize(name) ⇒ Playlist
constructor
A new instance of Playlist.
- #next ⇒ Object
- #next? ⇒ Boolean
- #previous ⇒ Object
- #previous? ⇒ Boolean
- #to_ary ⇒ Object
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
#name ⇒ Object (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 |
#next ⇒ Object
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
28 |
# File 'lib/airplay/player/playlist.rb', line 28 def next?; @position + 1 <= @items.size end |
#previous ⇒ Object
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
29 |
# File 'lib/airplay/player/playlist.rb', line 29 def previous?; @position - 1 >= 0 end |
#to_ary ⇒ Object
20 21 22 |
# File 'lib/airplay/player/playlist.rb', line 20 def to_ary @items end |