class Comet::DiskDrive
DiskDrive is a typed class wrapper around the underlying Comet Server API data structure.
def clear
def clear @id = '' @device_name = '' @caption = '' @model = '' @serial_number = '' @size = 0 @partitions = [] @device_parents = [] @flags = 0 @cylinders = 0 @heads = 0 @sectors = 0 @sector_size = 0 @unknown_json_fields = {} end
def from_hash(obj)
-
obj
(Hash
) -- The complete object as a Ruby hash
def from_hash(obj) raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash obj.each do |k, v| case k when 'ID' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @id = v when 'DeviceName' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @device_name = v when 'Caption' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @caption = v when 'Model' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @model = v when 'SerialNumber' raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String @serial_number = v when 'Size' raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric @size = v when 'Partitions' if v.nil? @partitions = [] else @partitions = Array.new(v.length) v.each_with_index do |v1, i1| @partitions[i1] = Comet::Partition.new @partitions[i1].from_hash(v1) end end when 'DeviceParents' if v.nil? @device_parents = [] else @device_parents = Array.new(v.length) v.each_with_index do |v1, i1| raise TypeError, "'v1' expected String, got #{v1.class}" unless v1.is_a? String @device_parents[i1] = v1 end end when 'Flags' raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric @flags = v when 'Cylinders' raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric @cylinders = v when 'Heads' raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric @heads = v when 'Sectors' raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric @sectors = v when 'SectorSize' raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric @sector_size = v else @unknown_json_fields[k] = v end end end
def from_json(json_string)
-
json_string
(String
) -- The complete object in JSON format
def from_json(json_string) raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String from_hash(JSON.parse(json_string)) end
def initialize
def initialize clear end
def to_h
-
(Hash)
- The complete object as a Ruby hash
def to_h to_hash end
def to_hash
-
(Hash)
- The complete object as a Ruby hash
def to_hash ret = {} ret['ID'] = @id ret['DeviceName'] = @device_name ret['Caption'] = @caption ret['Model'] = @model ret['SerialNumber'] = @serial_number ret['Size'] = @size ret['Partitions'] = @partitions ret['DeviceParents'] = @device_parents ret['Flags'] = @flags ret['Cylinders'] = @cylinders ret['Heads'] = @heads ret['Sectors'] = @sectors ret['SectorSize'] = @sector_size @unknown_json_fields.each do |k, v| ret[k] = v end ret end
def to_json(options = {})
-
(String)
- The complete object as a JSON string
def to_json(options = {}) to_hash.to_json(options) end