Class: RbPod::Device
- Inherits:
-
Object
- Object
- RbPod::Device
- Defined in:
- ext/rbpod/device.c
Instance Method Summary collapse
-
#[](key) ⇒ String
Returns the SysInfo entry for the given key, or nil.
-
#[]=(key, value) ⇒ nil
Sets the given SysInfo entry to a value and returns nil.
-
#capacity ⇒ Float
Returns the capacity of the device in gigabytes (GB).
-
#generation ⇒ String
Returns the generation of the device.
-
#initialize(mount_point) ⇒ RbPod::Device
constructor
Creates an RbPod::Device mapped to a given device mount point.
-
#model_name ⇒ String
Returns the model name of the device.
-
#model_number ⇒ String
Returns the model number of the device.
-
#save! ⇒ nil
Writes the SysInfo data back to the device.
-
#supports_artwork? ⇒ Boolean
Returns true of false if the device supports artwork.
-
#supports_chapter_images? ⇒ Boolean
Returns true of false if the device supports chapter images.
-
#supports_photos? ⇒ Boolean
Returns true of false if the device supports photos.
-
#supports_podcasts? ⇒ Boolean
Returns true of false if the device supports podcasts.
-
#supports_videos? ⇒ Boolean
Returns true of false if the device supports videos.
-
#uuid ⇒ String
Returns the UUID of the device.
Constructor Details
#initialize(mount_point) ⇒ RbPod::Device
Creates an RbPod::Device mapped to a given device mount point.
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'ext/rbpod/device.c', line 193
static VALUE rbpod_device_initialize(VALUE self, VALUE mount_point)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
/* Check if the mount point is a directory. */
if (rb_file_directory_p(rb_cFile, mount_point) != Qtrue) {
rb_raise(eRbPodError, "The mount point must be a directory!");
return Qnil;
}
itdb_device_set_mountpoint(device, StringValueCStr(mount_point));
DATA_PTR(self) = device;
return self;
}
|
Instance Method Details
#[](key) ⇒ String
Returns the SysInfo entry for the given key, or nil.
136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'ext/rbpod/device.c', line 136
static VALUE rbpod_device_sysinfo_get(VALUE self, VALUE key)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
gchar *value = NULL;
VALUE result;
value = itdb_device_get_sysinfo(device, StringValueCStr(key));
result = (value == NULL) ? Qnil : rb_str_new2(value);
g_free(value);
return result;
}
|
#[]=(key, value) ⇒ nil
Sets the given SysInfo entry to a value and returns nil.
156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'ext/rbpod/device.c', line 156
static VALUE rbpod_device_sysinfo_set(VALUE self, VALUE key, VALUE value)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
gchar *_value, *_key;
_key = StringValueCStr(key);
_value = !NIL_P(value) ? StringValueCStr(value) : NULL;
itdb_device_set_sysinfo(device, _key, _value);
return Qnil;
}
|
#capacity ⇒ Float
Returns the capacity of the device in gigabytes (GB).
110 111 112 113 114 115 |
# File 'ext/rbpod/device.c', line 110
static VALUE rbpod_device_capacity_get(VALUE self)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
const Itdb_IpodInfo *info = itdb_device_get_ipod_info(device);
return DBL2NUM(info->capacity);
}
|
#generation ⇒ String
Returns the generation of the device.
97 98 99 100 101 102 |
# File 'ext/rbpod/device.c', line 97
static VALUE rbpod_device_generation_get(VALUE self)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
const Itdb_IpodInfo *info = itdb_device_get_ipod_info(device);
return rb_str_new2(itdb_info_get_ipod_generation_string(info->ipod_generation));
}
|
#model_name ⇒ String
Returns the model name of the device.
71 72 73 74 75 76 |
# File 'ext/rbpod/device.c', line 71
static VALUE rbpod_device_model_name_get(VALUE self)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
const Itdb_IpodInfo *info = itdb_device_get_ipod_info(device);
return rb_str_new2(itdb_info_get_ipod_model_name_string(info->ipod_model));
}
|
#model_number ⇒ String
Returns the model number of the device.
84 85 86 87 88 89 |
# File 'ext/rbpod/device.c', line 84
static VALUE rbpod_device_model_number_get(VALUE self)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
const Itdb_IpodInfo *info = itdb_device_get_ipod_info(device);
return rb_str_new2(info->model_number);
}
|
#save! ⇒ nil
Writes the SysInfo data back to the device. Call this if you change any entries.
175 176 177 178 179 180 181 182 183 184 185 |
# File 'ext/rbpod/device.c', line 175
static VALUE rbpod_device_sysinfo_save(VALUE self)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
GError *error = NULL;
if (itdb_device_write_sysinfo(device, &error) == FALSE) {
return rbpod_raise_error(error);
}
return Qnil;
}
|
#supports_artwork? ⇒ Boolean
Returns true of false if the device supports artwork.
35 36 37 38 39 |
# File 'ext/rbpod/device.c', line 35
static VALUE rbpod_device_artwork_support_p(VALUE self)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
return BooleanValue(itdb_device_supports_artwork(device));
}
|
#supports_chapter_images? ⇒ Boolean
Returns true of false if the device supports chapter images.
11 12 13 14 15 |
# File 'ext/rbpod/device.c', line 11
static VALUE rbpod_device_chapter_image_support_p(VALUE self)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
return BooleanValue(itdb_device_supports_chapter_image(device));
}
|
#supports_photos? ⇒ Boolean
Returns true of false if the device supports photos.
59 60 61 62 63 |
# File 'ext/rbpod/device.c', line 59
static VALUE rbpod_device_photo_support_p(VALUE self)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
return BooleanValue(itdb_device_supports_photo(device));
}
|
#supports_podcasts? ⇒ Boolean
Returns true of false if the device supports podcasts.
23 24 25 26 27 |
# File 'ext/rbpod/device.c', line 23
static VALUE rbpod_device_podcast_support_p(VALUE self)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
return BooleanValue(itdb_device_supports_podcast(device));
}
|
#supports_videos? ⇒ Boolean
Returns true of false if the device supports videos.
47 48 49 50 51 |
# File 'ext/rbpod/device.c', line 47
static VALUE rbpod_device_video_support_p(VALUE self)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
return BooleanValue(itdb_device_supports_video(device));
}
|
#uuid ⇒ String
Returns the UUID of the device.
123 124 125 126 127 128 |
# File 'ext/rbpod/device.c', line 123
static VALUE rbpod_device_uuid_get(VALUE self)
{
Itdb_Device *device = TYPED_DATA_PTR(self, Itdb_Device);
const gchar *uuid = itdb_device_get_uuid(device);
return (uuid == NULL) ? Qnil : rb_str_new2(uuid);
}
|