Class: RbPod::Track
- Inherits:
-
Object
- Object
- RbPod::Track
- Defined in:
- ext/rbpod/track.c
Instance Method Summary collapse
-
#album ⇒ String
Returns the album for the track.
-
#artist ⇒ String
Returns the artist for the track.
-
#initialize ⇒ RbPod::Track
constructor
Creates a detached track.
-
#path ⇒ String
Returns the full path to the file backing this track on the device.
-
#title ⇒ String
Returns the title of the track.
-
#transferred? ⇒ Boolean
Returns true or false if this track has been transferred to the device.
-
#type ⇒ String
Returns a human-readable string describing the content of the track.
Constructor Details
#initialize ⇒ RbPod::Track
Creates a detached track. (Not managed by a database.)
121 122 123 124 |
# File 'ext/rbpod/track.c', line 121 static VALUE rbpod_track_initialize(VALUE self) { return self; } |
Instance Method Details
#album ⇒ String
Returns the album for the track.
85 86 87 88 89 |
# File 'ext/rbpod/track.c', line 85 static VALUE rbpod_track_album_get(VALUE self) { Itdb_Track *track = TYPED_DATA_PTR(self, Itdb_Track); return rb_str_new2(track->album); } |
#artist ⇒ String
Returns the artist for the track.
73 74 75 76 77 |
# File 'ext/rbpod/track.c', line 73 static VALUE rbpod_track_artist_get(VALUE self) { Itdb_Track *track = TYPED_DATA_PTR(self, Itdb_Track); return rb_str_new2(track->artist); } |
#path ⇒ String
Returns the full path to the file backing this track on the device.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'ext/rbpod/track.c', line 24 static VALUE rbpod_track_path_get(VALUE self) { Itdb_Track *track = TYPED_DATA_PTR(self, Itdb_Track); VALUE mount_point, path_parts, file_path, full_path; Itdb_iTunesDB *database = track->itdb; const gchar *ipod_path = NULL; /* Never hurts to be careful, right? */ if (database == NULL || track->ipod_path == NULL) { return Qnil; } /* Skip the prepended directory separator. */ ipod_path = (const gchar *) &track->ipod_path[1]; /* Extract the iPod mount point from the database pointer. */ mount_point = rb_str_new2(itdb_get_mountpoint(database)); /* Split the track's ipod_path by ':' character. */ path_parts = rb_str_split(rb_str_new2(ipod_path), ":"); /* Use File.join to rejoin the path safely. */ file_path = rb_funcall2(rb_cFile, rb_intern("join"), 1, &path_parts); /* Retrieve the expanded absolute path name. */ full_path = (file_path, mount_point); /* Return a Pathname instance for the resolved path. */ return rb_class_new_instance(1, &full_path, rb_cPathname); } |
#title ⇒ String
Returns the title of the track.
97 98 99 100 101 |
# File 'ext/rbpod/track.c', line 97 static VALUE rbpod_track_title_get(VALUE self) { Itdb_Track *track = TYPED_DATA_PTR(self, Itdb_Track); return rb_str_new2(track->title); } |
#transferred? ⇒ Boolean
Returns true or false if this track has been transferred to the device.
12 13 14 15 16 |
# File 'ext/rbpod/track.c', line 12 static VALUE rbpod_track_transferred_p(VALUE self) { Itdb_Track *track = TYPED_DATA_PTR(self, Itdb_Track); return BooleanValue(track->transferred); } |
#type ⇒ String
Returns a human-readable string describing the content of the track.
61 62 63 64 65 |
# File 'ext/rbpod/track.c', line 61 static VALUE rbpod_track_type_get(VALUE self) { Itdb_Track *track = TYPED_DATA_PTR(self, Itdb_Track); return rb_str_new2(track->filetype); } |