Class: RVM::Classes::Object

Inherits:
Class
  • Object
show all
Defined in:
lib/rvm/classes/object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Class

#is_true?, #method_missing, #method_missing_old_class

Methods included from Plugin

#helper, #included, #plugin_host, #plugin_id, #register_for

Constructor Details

#initialize(objectClass) ⇒ Object

Returns a new instance of Object.



9
10
11
12
13
14
15
# File 'lib/rvm/classes/object.rb', line 9

def initialize objectClass
  super()
  @object_class = objectClass
  @functions = {}
  @variables = {}
  
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RVM::Classes::Class

Instance Attribute Details

#functionsObject (readonly)

Returns the value of attribute functions.



5
6
7
# File 'lib/rvm/classes/object.rb', line 5

def functions
  @functions
end

#object_classObject (readonly)

Returns the value of attribute object_class.



7
8
9
# File 'lib/rvm/classes/object.rb', line 7

def object_class
  @object_class
end

#variablesObject (readonly)

Returns the value of attribute variables.



6
7
8
# File 'lib/rvm/classes/object.rb', line 6

def variables
  @variables
end

Instance Method Details

#data_typeObject



25
26
27
# File 'lib/rvm/classes/object.rb', line 25

def data_type
  :object
end

#obj_send(method, params, env) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/rvm/classes/object.rb', line 17

def obj_send(method, params, env)
  m = @functions[method] || @object_class.object_functions(method)
  raise "Unknown method #{method} for object #{self}" if not m
  params.unshift self
  env = RVM::Interpreter::Enviroment.new({:params => params||[], :locals => @variables}, env)
  m.call(params, env)
end