Class: Net::DAAP::Database
- Inherits:
-
Object
- Object
- Net::DAAP::Database
- Defined in:
- lib/net/daap/database.rb
Overview
This class contains a database found on an iTunes server.
Constant Summary collapse
- @@SONG_ATTRIBUTES =
%w{ dmap.itemid dmap.itemname dmap.persistentid daap.songalbum daap.songartist daap.songformat daap.songsize }
Instance Attribute Summary collapse
-
#containercount ⇒ Object
readonly
Returns the value of attribute containercount.
-
#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) ⇒ Database
constructor
A new instance of Database.
-
#playlists ⇒ Object
Returns the playlists associated with this database.
Constructor Details
#initialize(args) ⇒ Database
Returns a new instance of Database.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/net/daap/database.rb', line 26 def initialize(args) @persistentid = args['dmap.persistentid'] @name = args['dmap.itemname'] @containercount = args['dmap.containercount'] @id = args['dmap.itemid'] @itemcount = args['dmap.itemcount'] @daap = args[:daap] @songs = [] @artists = [] @albums = [] load_songs end |
Instance Attribute Details
#containercount ⇒ Object (readonly)
Returns the value of attribute containercount.
19 20 21 |
# File 'lib/net/daap/database.rb', line 19 def containercount @containercount end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
19 20 21 |
# File 'lib/net/daap/database.rb', line 19 def id @id end |
#itemcount ⇒ Object (readonly)
Returns the value of attribute itemcount.
19 20 21 |
# File 'lib/net/daap/database.rb', line 19 def itemcount @itemcount end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
19 20 21 |
# File 'lib/net/daap/database.rb', line 19 def name @name end |
#persistentid ⇒ Object (readonly)
Returns the value of attribute persistentid.
19 20 21 |
# File 'lib/net/daap/database.rb', line 19 def persistentid @persistentid end |
Instance Method Details
#playlists ⇒ Object
Returns the playlists associated with this database
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/net/daap/database.rb', line 40 def playlists url = "databases/#{@id}/containers?meta=dmap.itemid,dmap.itemname,dmap.persistentid,com.apple.itunes.smart-playlist" res = @daap.do_get(url) listings = @daap.dmap.find(res, "daap.databaseplaylists/dmap.listing") playlists = [] @daap.unpack_listing(listings) do |value| playlist = Playlist.new( value.merge( :daap => @daap, :db => self )) if block_given? yield playlist else playlists << playlist end end playlists end |