Class: MPD::Controller::Playlists::Playlist

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/mpd/controller/playlists.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(playlists, name, last_modified = nil) ⇒ Playlist

Returns a new instance of Playlist.



19
20
21
22
23
# File 'lib/mpd/controller/playlists.rb', line 19

def initialize (playlists, name, last_modified = nil)
  @playlists     = playlists
  @name          = name
  @last_modified = last_modified
end

Instance Attribute Details

#last_modifiedObject (readonly)

Returns the value of attribute last_modified.



17
18
19
# File 'lib/mpd/controller/playlists.rb', line 17

def last_modified
  @last_modified
end

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/mpd/controller/playlists.rb', line 17

def name
  @name
end

#playlistsObject (readonly)

Returns the value of attribute playlists.



17
18
19
# File 'lib/mpd/controller/playlists.rb', line 17

def playlists
  @playlists
end

Instance Method Details

#add(uri) ⇒ Object



53
54
55
# File 'lib/mpd/controller/playlists.rb', line 53

def add (uri)
  playlists.controller.do_and_raise_if_needed :playlistadd, name, uri
end

#clearObject



63
64
65
66
67
# File 'lib/mpd/controller/playlists.rb', line 63

def clear
  playlists.controller.do_and_raise_if_needed :playlistclear, name

  self
end

#delete!Object



47
48
49
50
51
# File 'lib/mpd/controller/playlists.rb', line 47

def delete!
  playlists.controller.do_and_raise_if_needed :rm, name

  self
end

#eachObject



25
26
27
28
29
30
31
32
33
# File 'lib/mpd/controller/playlists.rb', line 25

def each
  return to_enum unless block_given?

  Database::Song.from_data(playlists.controller.do_and_raise_if_needed(:listplaylistinfo, name)).each {|song|
    yield song
  }

  self
end

#load(range = nil) ⇒ Object



35
36
37
38
39
# File 'lib/mpd/controller/playlists.rb', line 35

def load (range = nil)
  playlists.controller.do_and_raise_if_needed :load, name, *range

  self
end

#move(from, to) ⇒ Object



57
58
59
60
61
# File 'lib/mpd/controller/playlists.rb', line 57

def move (from, to)
  playlists.controller.do_and_raise_if_needed :playlistmove, name, from, to

  self
end

#rename(new) ⇒ Object



41
42
43
44
45
# File 'lib/mpd/controller/playlists.rb', line 41

def rename (new)
  playlists.controller.do_and_raise_if_needed :rename, name, new

  self
end