class Comet::StoredObject

StoredObject is a typed class wrapper around the underlying Comet Server API data structure.

def clear

def clear
  @name = ''
  @modify_time = 0
  @type = ''
  @subtree = ''
  @size = 0
  @display_name = ''
  @item_class = ''
  @from = ''
  @to = ''
  @received_date_time = 0
  @start_time = 0
  @end_time = 0
  @recursive_files = 0
  @recursive_bytes = 0
  @recursive_folders = 0
  @unknown_json_fields = {}
end

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 'name'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
      @name = v
    when 'mtime'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
      @modify_time = v
    when 'type'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
      @type = v
    when 'subtree'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
      @subtree = v
    when 'size'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
      @size = v
    when 'dname'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
      @display_name = v
    when 'itemClass'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
      @item_class = v
    when 'from'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
      @from = v
    when 'to'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String
      @to = v
    when 'rtime'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
      @received_date_time = v
    when 'has_attachments'
      @has_attachments = v
    when 'stime'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
      @start_time = v
    when 'etime'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
      @end_time = v
    when 'r'
      @recursive_count_known = v
    when 'f'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
      @recursive_files = v
    when 'b'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
      @recursive_bytes = v
    when 'd'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric
      @recursive_folders = v
    else
      @unknown_json_fields[k] = v
    end
  end
end

def from_json(json_string)

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

Returns:
  • (Hash) - The complete object as a Ruby hash
def to_h
  to_hash
end

def to_hash

Returns:
  • (Hash) - The complete object as a Ruby hash
def to_hash
  ret = {}
  ret['name'] = @name
  ret['mtime'] = @modify_time
  ret['type'] = @type
  ret['subtree'] = @subtree
  ret['size'] = @size
  unless @display_name.nil?
    ret['dname'] = @display_name
  end
  unless @item_class.nil?
    ret['itemClass'] = @item_class
  end
  unless @from.nil?
    ret['from'] = @from
  end
  unless @to.nil?
    ret['to'] = @to
  end
  unless @received_date_time.nil?
    ret['rtime'] = @received_date_time
  end
  unless @has_attachments.nil?
    ret['has_attachments'] = @has_attachments
  end
  unless @start_time.nil?
    ret['stime'] = @start_time
  end
  unless @end_time.nil?
    ret['etime'] = @end_time
  end
  unless @recursive_count_known.nil?
    ret['r'] = @recursive_count_known
  end
  unless @recursive_files.nil?
    ret['f'] = @recursive_files
  end
  unless @recursive_bytes.nil?
    ret['b'] = @recursive_bytes
  end
  unless @recursive_folders.nil?
    ret['d'] = @recursive_folders
  end
  @unknown_json_fields.each do |k, v|
    ret[k] = v
  end
  ret
end

def to_json(options = {})

Returns:
  • (String) - The complete object as a JSON string
def to_json(options = {})
  to_hash.to_json(options)
end