class Comet::DiskDrive

def from_hash(obj)

Parameters:
  • 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