Class: RbPod::PlaylistCollection
- Inherits:
-
Object
- Object
- RbPod::PlaylistCollection
- Defined in:
- ext/rbpod/playlist_collection.c
Instance Method Summary collapse
-
#database ⇒ RbPod::Database
Returns the database this playlist collection is attached to.
-
#include?(playlist) ⇒ Boolean
Returns true or false if the given RbPod::Playlist
playlistexists within the database. -
#initialize(database) ⇒ RbPod::PlaylistCollection
constructor
Given an RbPod::Database
databasecreates a collection of playlists from it. -
#master ⇒ RbPod::Playlist
Returns the master playlist from the database.
-
#podcast ⇒ RbPod::Playlist
Returns the podcast playlist from the database.
Constructor Details
#initialize(database) ⇒ RbPod::PlaylistCollection
Given an RbPod::Database database creates a collection of playlists from it.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'ext/rbpod/playlist_collection.c', line 86 static VALUE rbpod_playlist_collection_initialize(VALUE self, VALUE database) { Itdb_iTunesDB *_database = TYPED_DATA_PTR(database, Itdb_iTunesDB); if (rb_obj_is_instance_of(database, cRbPodDatabase) == FALSE) { rb_raise(eRbPodError, "Invalid Arguments: Expected RbPod::Database, got %s", StringValueCStr(database)); return Qnil; } rb_iv_set(self, "@database", database); DATA_PTR(self) = _database->playlists; return self; } |
Instance Method Details
#database ⇒ RbPod::Database
Returns the database this playlist collection is attached to.
15 16 17 18 |
# File 'ext/rbpod/playlist_collection.c', line 15 static VALUE rbpod_playlist_collection_database(VALUE self) { return rb_iv_get(self, "@database"); } |
#include?(playlist) ⇒ Boolean
Returns true or false if the given RbPod::Playlist playlist exists within the database.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'ext/rbpod/playlist_collection.c', line 26 static VALUE rbpod_playlist_collection_include_p(VALUE self, VALUE playlist) { VALUE database = rbpod_playlist_collection_database(self); Itdb_iTunesDB *_database = TYPED_DATA_PTR(database, Itdb_iTunesDB); Itdb_Playlist *_playlist = TYPED_DATA_PTR(playlist, Itdb_Playlist); if (rb_obj_is_instance_of(playlist, cRbPodPlaylist) == FALSE) { rb_raise(eRbPodError, "Invalid argument: expected RbPod::Playlist, got %s", StringValueCStr(playlist)); return Qfalse; } return BooleanValue(itdb_playlist_exists(_database, _playlist)); } |
#master ⇒ RbPod::Playlist
Returns the master playlist from the database.
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'ext/rbpod/playlist_collection.c', line 46 static VALUE rbpod_playlist_collection_master(VALUE self) { VALUE database = rbpod_playlist_collection_database(self); Itdb_iTunesDB *_database = TYPED_DATA_PTR(database, Itdb_iTunesDB); Itdb_Playlist *_playlist = itdb_playlist_mpl(_database); if (_playlist == NULL) { return Qnil; } /* Create a new instance of the master playlist from the data provided. */ return rb_class_new_instance_with_data(0, NULL, cRbPodPlaylist, _playlist); } |
#podcast ⇒ RbPod::Playlist
Returns the podcast playlist from the database.
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'ext/rbpod/playlist_collection.c', line 66 static VALUE rbpod_playlist_collection_podcast(VALUE self) { VALUE database = rbpod_playlist_collection_database(self); Itdb_iTunesDB *_database = TYPED_DATA_PTR(database, Itdb_iTunesDB); Itdb_Playlist *_playlist = itdb_playlist_podcasts(_database); if (_playlist == NULL) { return Qnil; } /* Create a new instance of the podcast playlist from the data provided. */ return rb_class_new_instance_with_data(0, NULL, cRbPodPlaylist, _playlist); } |