Class: RbPod::Playlist
- Inherits:
-
Object
- Object
- RbPod::Playlist
- Defined in:
- ext/rbpod/playlist.c
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
Compares two playlists based on their names.
-
#created_on ⇒ Time
Returns a Time object representing the time that this playlist was created.
-
#initialize ⇒ RbPod::Playlist
constructor
Creates a detached playlist.
-
#length ⇒ Integer
Returns the total number of tracks in this playlist.
-
#master? ⇒ Boolean
Returns true or false if this playlist is the master playlist.
-
#name ⇒ String
Returns the name of this playlist.
-
#name=(string) ⇒ nil
Sets the name of this playlist.
-
#podcast? ⇒ Boolean
Returns true or false if this playlist is the podcast-only playlist.
-
#shuffle! ⇒ nil
Shuffles the tracks in this playlist in place.
-
#smart=(flag) ⇒ nil
Set this playlist to a smart playlist.
-
#smart? ⇒ Boolean
Returns true or false if this playlist is a smart playlist.
-
#tracks ⇒ RbPod::Collection
Returns a collection of the tracks in this playlist.
Constructor Details
#initialize ⇒ RbPod::Playlist
Creates a detached playlist. (Not managed by the database.)
175 176 177 178 179 |
# File 'ext/rbpod/playlist.c', line 175
static VALUE rbpod_playlist_initialize(VALUE self)
{
/* Nothing to see here. */
return self;
}
|
Instance Method Details
#<=>(other) ⇒ Integer
Compares two playlists based on their names.
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'ext/rbpod/playlist.c', line 143
static VALUE rbpod_playlist_compare(VALUE self, VALUE other)
{
VALUE this_playlist_name, other_playlist_name;
if (rb_class_of(other) != cRbPodPlaylist) {
rb_raise(eRbPodError, "Can't compare a Playlist with %s", StringValueCStr(other));
return Qnil;
}
/* If this is the master playlist, it always comes first. */
if (rbpod_playlist_master_p(self) == Qtrue) {
return NUM2INT(-1);
}
/* If we're comparing against the master playlist, it comes first. */
if (rbpod_playlist_master_p(other) == Qtrue) {
return NUM2INT(1);
}
this_playlist_name = rbpod_playlist_name_get(self);
other_playlist_name = rbpod_playlist_name_get(other);
/* Otherwise, compare by playlist name. */
return rb_str_cmp(this_playlist_name, other_playlist_name);
}
|
#created_on ⇒ Time
Returns a Time object representing the time that this playlist was created.
62 63 64 65 66 |
# File 'ext/rbpod/playlist.c', line 62
static VALUE rbpod_playlist_timestamp_get(VALUE self)
{
Itdb_Playlist *playlist = TYPED_DATA_PTR(self, Itdb_Playlist);
return rb_funcall(rb_cTime, rb_intern("at"), 1, INT2NUM(playlist->timestamp));
}
|
#length ⇒ Integer
Returns the total number of tracks in this playlist.
98 99 100 101 102 |
# File 'ext/rbpod/playlist.c', line 98
static VALUE rbpod_playlist_length_get(VALUE self)
{
Itdb_Playlist *playlist = TYPED_DATA_PTR(self, Itdb_Playlist);
return INT2NUM(itdb_playlist_tracks_number(playlist));
}
|
#master? ⇒ Boolean
Returns true or false if this playlist is the master playlist.
23 24 25 26 27 |
# File 'ext/rbpod/playlist.c', line 23
static VALUE rbpod_playlist_master_p(VALUE self)
{
Itdb_Playlist *playlist = TYPED_DATA_PTR(self, Itdb_Playlist);
return BooleanValue(itdb_playlist_is_mpl(playlist));
}
|
#name ⇒ String
Returns the name of this playlist.
131 132 133 134 135 |
# File 'ext/rbpod/playlist.c', line 131
static VALUE rbpod_playlist_name_get(VALUE self)
{
Itdb_Playlist *playlist = TYPED_DATA_PTR(self, Itdb_Playlist);
return rb_str_new2(playlist->name);
}
|
#name=(string) ⇒ nil
Sets the name of this playlist.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'ext/rbpod/playlist.c', line 110
static VALUE rbpod_playlist_name_set(VALUE self, VALUE name)
{
Itdb_Playlist *playlist = TYPED_DATA_PTR(self, Itdb_Playlist);
gchar *new_name = StringValueCStr(name);
gchar *old_name = playlist->name;
/* Free up the old name. */
g_free(old_name);
/* Attach the new name. */
playlist->name = new_name;
return Qnil;
}
|
#podcast? ⇒ Boolean
Returns true or false if this playlist is the podcast-only playlist.
11 12 13 14 15 |
# File 'ext/rbpod/playlist.c', line 11
static VALUE rbpod_playlist_podcast_p(VALUE self)
{
Itdb_Playlist *playlist = TYPED_DATA_PTR(self, Itdb_Playlist);
return BooleanValue(itdb_playlist_is_podcasts(playlist));
}
|
#shuffle! ⇒ nil
Shuffles the tracks in this playlist in place.
74 75 76 77 78 79 |
# File 'ext/rbpod/playlist.c', line 74
static VALUE rbpod_playlist_shuffle_bang(VALUE self)
{
Itdb_Playlist *playlist = TYPED_DATA_PTR(self, Itdb_Playlist);
itdb_playlist_randomize(playlist);
return Qnil;
}
|
#smart=(flag) ⇒ nil
Set this playlist to a smart playlist.
47 48 49 50 51 52 53 54 |
# File 'ext/rbpod/playlist.c', line 47
static VALUE rbpod_playlist_smart_set(VALUE self, VALUE flag)
{
Itdb_Playlist *playlist = TYPED_DATA_PTR(self, Itdb_Playlist);
playlist->is_spl = (RTEST(flag)) ? TRUE : FALSE;
return Qnil;
}
|
#smart? ⇒ Boolean
Returns true or false if this playlist is a smart playlist.
35 36 37 38 39 |
# File 'ext/rbpod/playlist.c', line 35
static VALUE rbpod_playlist_smart_p(VALUE self)
{
Itdb_Playlist *playlist = TYPED_DATA_PTR(self, Itdb_Playlist);
return BooleanValue(playlist->is_spl);
}
|
#tracks ⇒ RbPod::Collection
Returns a collection of the tracks in this playlist.
87 88 89 90 |
# File 'ext/rbpod/playlist.c', line 87
static VALUE rbpod_playlist_tracks_get(VALUE self)
{
return rb_class_new_instance(1, &self, cRbPodTrackCollection);
}
|