Class: MPD::Controller::Playlists
- Inherits:
-
Object
- Object
- MPD::Controller::Playlists
- Includes:
- Enumerable
- Defined in:
- lib/mpd/controller/playlists.rb
Defined Under Namespace
Classes: Playlist
Instance Attribute Summary collapse
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #delete(name) ⇒ Object
- #each ⇒ Object
-
#initialize(controller) ⇒ Playlists
constructor
A new instance of Playlists.
Constructor Details
#initialize(controller) ⇒ Playlists
Returns a new instance of Playlists.
74 75 76 |
# File 'lib/mpd/controller/playlists.rb', line 74 def initialize (controller) @controller = controller end |
Instance Attribute Details
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
72 73 74 |
# File 'lib/mpd/controller/playlists.rb', line 72 def controller @controller end |
Instance Method Details
#[](name) ⇒ Object
78 79 80 |
# File 'lib/mpd/controller/playlists.rb', line 78 def [] (name) find { |p| p.name == name.to_s } end |
#delete(name) ⇒ Object
82 83 84 |
# File 'lib/mpd/controller/playlists.rb', line 82 def delete (name) self[name].delete! rescue nil end |
#each ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/mpd/controller/playlists.rb', line 86 def each return to_enum unless block_given? name = nil last_modified = nil controller.do_and_raise_if_needed(:listplaylists).each {|key, value| if key == :playlist if last_modified yield Playlist.new(self, name, last_modified) end name = value last_modified = nil elsif key == :"Last-Modified" last_modified = value end } if name yield Playlist.new(self, name, last_modified) end self end |