Class: Net::DAAP::Playlist
- Inherits:
-
Object
- Object
- Net::DAAP::Playlist
- Defined in:
- lib/net/daap/playlist.rb
Overview
server.
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#itemcount ⇒ Object
readonly
Returns the value of attribute itemcount.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#persistentid ⇒ Object
readonly
Returns the value of attribute persistentid.
Instance Method Summary collapse
-
#initialize(args) ⇒ Playlist
constructor
A new instance of Playlist.
-
#songs ⇒ Object
Returns a list of songs associated with this playlist.
Constructor Details
#initialize(args) ⇒ Playlist
Returns a new instance of Playlist.
8 9 10 11 12 13 14 15 16 |
# File 'lib/net/daap/playlist.rb', line 8 def initialize(args) info = args[:pl_info] @itemcount = info['dmap.itemcount'] @persistentid = info['dmap.persistentid'] @name = info['dmap.itemname'] @id = info['dmap.itemid'] @daap = args[:daap] @db = args[:db] end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/net/daap/playlist.rb', line 6 def id @id end |
#itemcount ⇒ Object (readonly)
Returns the value of attribute itemcount.
6 7 8 |
# File 'lib/net/daap/playlist.rb', line 6 def itemcount @itemcount end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/net/daap/playlist.rb', line 6 def name @name end |
#persistentid ⇒ Object (readonly)
Returns the value of attribute persistentid.
6 7 8 |
# File 'lib/net/daap/playlist.rb', line 6 def persistentid @persistentid end |
Instance Method Details
#songs ⇒ Object
Returns a list of songs associated with this playlist.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/net/daap/playlist.rb', line 19 def songs path = "databases/#{@db.id}/containers/#{@id}/items?type=music&meta=dmap.itemkind,dmap.itemid,dmap.containeritemid" result = @daap.do_get(path) listings = @daap.dmap.find(result, "daap.playlistsongs/dmap.listing") songs = [] @daap.unpack_listing(listings) do |value| if block_given? yield @db.songs.find { |s| s.id == value['dmap.itemid'] } else songs << @db.songs.find { |s| s.id == value['dmap.itemid'] } end end songs end |