Class Irmo::World
In: rbirmo.c
Parent: Object
Methods
[]    each    each_of_class    get_object_for_id    initialize    method_call    new    new_object    spec    watch    watch_class    watch_destroy    watch_method    watch_new   
Public Class methods
new(VALUE klass, VALUE ifspec)

Create a new world.

You must pass an InterfaceSpec object defining the interface to the world.

  world = Irmo::World.new(spec)
Public Instance methods
initialize(p1)
get_object_for_id(VALUE self, VALUE objid)

Find an Object from its World ID.

  # Get object number 98

  obj = world[98]
  # Get object number 26

  obj = world.get_object_for_id(26)
each(VALUE self)

Iterate over all Objects in the world.

  # Iterate over all objects

  world.each { |obj| ... }
spec(VALUE self)

Get the InterfaceSpec object being used for this world

each_of_class(VALUE self, VALUE classname)

Iterate over all Objects in the world of a particular class.

  # Iterate over all objects of class 'Rocket'

  world.each_of('Rocket') { |obj| ... }
new_object(VALUE self, VALUE classname)

Create a new Object in the world.

Pass the name of the class of object to create. Returns the new Object.

  # Create a new object of class 'Spaceship'

  obj = world.new_object('Spaceship')
method_call(int argc, VALUE *argv, VALUE self)

Call a method on the world

Pass the method name and then the arguments to the method.

  # call method 'jump', with arguments '5' and 'hello'

  world.call('jump', 5, 'hello')
[](VALUE self, VALUE objid)

Find an Object from its World ID.

  # Get object number 98

  obj = world[98]
  # Get object number 26

  obj = world.get_object_for_id(26)
watch_new(int argc, VALUE *argv, VALUE self)

Set a callback watching for new Objects. Usage:

  # Watch for all new objects

  world.watch_new { |obj| ... }
  # Watch for all new objects of a particular class

  world.watch_new('classname') { |obj| ... }

Returns a Callback object representing the callback.

watch_destroy(int argc, VALUE *argv, VALUE self)

Set a callback watching for objects being destroyed. Usage:

  # Watch for all objects being destroyed

  world.watch_destroy { |obj| ... }
  # Watch all objects of a particular class

  world.watch_new('classname') { |obj| ... }

Returns a Callback object representing the callback.

watch_class(int argc, VALUE *argv, VALUE self)

Watch for changes to object variables. Usage:

  # Watch for changes to all variables on all objects.

  world.watch_class { |obj,var| ... }
  # Watch for all changes to objects in a particular class.

  world.watch_class('classname') { |obj,var| ... }
  # Watch for changes to a particular variable in a particular class.

  world.watch_class('classname', 'varname') { |obj,var| ... }

Returns a Callback object representing the callback.

watch(int argc, VALUE *argv, VALUE self)

Watch for changes to object variables. Usage:

  # Watch for changes to all variables on all objects.

  world.watch_class { |obj,var| ... }
  # Watch for all changes to objects in a particular class.

  world.watch_class('classname') { |obj,var| ... }
  # Watch for changes to a particular variable in a particular class.

  world.watch_class('classname', 'varname') { |obj,var| ... }

Returns a Callback object representing the callback.

watch_method(VALUE self, VALUE method_name)

Watch for method calls to the world. Usage:

  world.watch_method('methodname') { |arg1,arg2| ... }

Returns a Callback object representing the callback.