Class: MTP::Storage

Inherits:
Object
  • Object
show all
Defined in:
lib/mtp/storage.rb

Constant Summary collapse

TYPES =
{ 
  0x0000 => "Undefined", 0x0001 => "Fixed ROM", 0x0002 => "Removable ROM",
  0x0003 => "Fixed RAM", 0x0004 => "Removable RAM"
}
FILE_SYSTEMS =
{
  0x0000 => "Undefined", 0x0001 => "Generic Flat", 0x0002 => "Generic Hierarchical", 0x0003 => "DCF"
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_capabilityObject (readonly)

Returns the value of attribute access_capability.



3
4
5
# File 'lib/mtp/storage.rb', line 3

def access_capability
  @access_capability
end

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/mtp/storage.rb', line 3

def description
  @description
end

#file_systemObject (readonly)

Returns the value of attribute file_system.



3
4
5
# File 'lib/mtp/storage.rb', line 3

def file_system
  @file_system
end

#free_space_in_bytesObject (readonly)

Returns the value of attribute free_space_in_bytes.



3
4
5
# File 'lib/mtp/storage.rb', line 3

def free_space_in_bytes
  @free_space_in_bytes
end

#free_space_in_objectsObject (readonly)

Returns the value of attribute free_space_in_objects.



3
4
5
# File 'lib/mtp/storage.rb', line 3

def free_space_in_objects
  @free_space_in_objects
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/mtp/storage.rb', line 3

def id
  @id
end

#max_capabilityObject (readonly)

Returns the value of attribute max_capability.



3
4
5
# File 'lib/mtp/storage.rb', line 3

def max_capability
  @max_capability
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/mtp/storage.rb', line 3

def type
  @type
end

#volume_labelObject (readonly)

Returns the value of attribute volume_label.



3
4
5
# File 'lib/mtp/storage.rb', line 3

def volume_label
  @volume_label
end

Class Method Details

.load(ph, id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mtp/storage.rb', line 16

def self.load(ph, id)
  storage = Storage.new
  t = ph.transaction.get_storage_info(id)
  t.expect("OK")
  storage.instance_eval do
    @id = id
    @type, @file_system, @access_capability, @max_capability, @free_space_in_bytes,
    @free_space_in_objects, @description, @volume_label =
      t.data.payload.unpack("SSSQQIJJ")
    @type = Datacode.new(@type, TYPES)
    @file_system = Datacode.new(@file_system, FILE_SYSTEMS)
  end
  storage
end

Instance Method Details

#file_system_descriptionObject



35
36
37
# File 'lib/mtp/storage.rb', line 35

def file_system_description
  FILE_SYSTEMS[@file_system]
end

#type_descriptionObject



31
32
33
# File 'lib/mtp/storage.rb', line 31

def type_description
  TYPES[@type]
end