class Root

The Root class is the mother of all objects.

Public Class Methods

new(name, owner) click to toggle source

Create a new Root

name

Every object needs a name

owner

The owner id of this object

return

A handle to the new Object

# File lib/core/root.rb, line 30
def initialize(name, owner)
  self.id                     # The database id of the object
  self.name = name            # The displayed name of the object
  self.owner = owner || id    # The owner of the object or itself.
  self.desc = ""              # The description of the object
  self.created_on = Time.now
  self.updated_on = created_on.dup
end

Public Instance Methods

add_event(from,to,kind,msg=nil) click to toggle source
# File lib/core/root.rb, line 76
def add_event(from,to,kind,msg=nil)
  Engine.instance.eventmgr.add_event(from,to,kind,msg)
end
clone() click to toggle source

Clone an object This does a deepcopy then assign a new database id

return

A handle to the new Object

# File lib/core/root.rb, line 54
def clone
  newobj = Marshal.load(Marshal.dump(self))
  props = newobj.instance_variable_get(:@props)
  props[:id] = Engine.instance.db.getid
  put_object(newobj)
  newobj
rescue
  log.error "Clone failed"
  nil
end
delete_object(oid) click to toggle source
# File lib/core/root.rb, line 88
def delete_object(oid)
  Engine.instance.db.delete(oid)
end
get_object(oid) click to toggle source
# File lib/core/root.rb, line 80
def get_object(oid)
  Engine.instance.db.get(oid)
end
inspect() click to toggle source

formatted dump of object properties

return

a string

# File lib/core/root.rb, line 41
def inspect
  s = ''
  @props.each do |key,val|
    s << sprintf("%-20.20s : %-40.40s\n", key.to_s, val.inspect)
  end
  s
end
parse(m) click to toggle source

All command input routed through here and parsed.

m

The input message to be parsed

return

false or true depending on whether command succeeded.

# File lib/core/root.rb, line 68
def parse(m)
  false
end
put_object(obj) click to toggle source
# File lib/core/root.rb, line 84
def put_object(obj)
  Engine.instance.db.put(obj)
end
world() click to toggle source
# File lib/core/root.rb, line 72
def world
  Engine.instance.db.get(0)
end