Class: RbPod::Track

Inherits:
Object
  • Object
show all
Defined in:
ext/rbpod/track.c

Instance Method Summary collapse

Constructor Details

#initializeRbPod::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

#albumString

Returns the album for the track.

Returns:

  • (String)


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);
}

#artistString

Returns the artist for the track.

Returns:

  • (String)


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);
}

#pathString

Returns the full path to the file backing this track on the device.

Returns:

  • (String)


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 = rb_file_expand_path(file_path, mount_point);

    /* Return a Pathname instance for the resolved path. */
    return rb_class_new_instance(1, &full_path, rb_cPathname);
}

#titleString

Returns the title of the track.

Returns:

  • (String)


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.

Returns:

  • (Boolean)


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);
}

#typeString

Returns a human-readable string describing the content of the track.

Returns:

  • (String)


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);
}