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(database) ⇒ RbPod::Device
constructor
Creates an RbPod::Device for a given RbPod::Database.
-
#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(database) ⇒ RbPod::Device
Creates an RbPod::Device for a given RbPod::Database. You shouldn’t have to call this.
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'ext/rbpod/device.c', line 196 static VALUE rbpod_device_initialize(VALUE self, VALUE database) { Itdb_iTunesDB *_database = TYPED_DATA_PTR(database, Itdb_iTunesDB); /* Make sure we were given an instance of a RbPod::Database. */ if (rb_obj_is_instance_of(database, cRbPodDatabase) == FALSE) { rb_raise(eRbPodError, "Given database must be an instance of RbPod::Database: %s", StringValueCStr(database)); return Qnil; } /* The database pointer and it's device should both be non-NULL. */ if (_database == NULL || _database->device == NULL) { rb_raise(eRbPodError, "Given database and/or device was NULL."); return Qnil; } /* Attach our data pointer to this database's backing device. */ DATA_PTR(self) = _database->device; return self; } |
Instance Method Details
#[](key) ⇒ String
Returns the SysInfo entry for the given key, or nil.
139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'ext/rbpod/device.c', line 139 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.
159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'ext/rbpod/device.c', line 159 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).
113 114 115 116 117 118 |
# File 'ext/rbpod/device.c', line 113 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.
100 101 102 103 104 105 |
# File 'ext/rbpod/device.c', line 100 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.
74 75 76 77 78 79 |
# File 'ext/rbpod/device.c', line 74 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.
87 88 89 90 91 92 |
# File 'ext/rbpod/device.c', line 87 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.
178 179 180 181 182 183 184 185 186 187 188 |
# File 'ext/rbpod/device.c', line 178 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.
38 39 40 41 42 |
# File 'ext/rbpod/device.c', line 38 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.
14 15 16 17 18 |
# File 'ext/rbpod/device.c', line 14 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.
62 63 64 65 66 |
# File 'ext/rbpod/device.c', line 62 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.
26 27 28 29 30 |
# File 'ext/rbpod/device.c', line 26 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.
50 51 52 53 54 |
# File 'ext/rbpod/device.c', line 50 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.
126 127 128 129 130 131 |
# File 'ext/rbpod/device.c', line 126 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); } |