Class: RVM::Classes::VMClass
Instance Attribute Summary collapse
-
#functions ⇒ Object
readonly
Returns the value of attribute functions.
-
#initializer ⇒ Object
Returns the value of attribute initializer.
-
#object_functions ⇒ Object
readonly
Returns the value of attribute object_functions.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
- #data_type ⇒ Object
-
#initialize(parent = nil, initialize_name = "create") ⇒ VMClass
constructor
A new instance of VMClass.
- #instance(params, env) ⇒ Object
- #obj_send(method, params, env) ⇒ Object
Methods inherited from Class
Methods included from Plugin
#helper, #included, #plugin_host, #plugin_id, #register_for
Constructor Details
#initialize(parent = nil, initialize_name = "create") ⇒ VMClass
Returns a new instance of VMClass.
17 18 19 20 21 22 23 24 |
# File 'lib/rvm/classes/class.rb', line 17 def initialize(parent = nil, initialize_name = "create"); super() @initializer = initialize_name @functions = {} @variables = {} @object_functions = {} @parent = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RVM::Classes::Class
Instance Attribute Details
#functions ⇒ Object (readonly)
Returns the value of attribute functions.
7 8 9 |
# File 'lib/rvm/classes/class.rb', line 7 def functions @functions end |
#initializer ⇒ Object
Returns the value of attribute initializer.
10 11 12 |
# File 'lib/rvm/classes/class.rb', line 10 def initializer @initializer end |
#object_functions ⇒ Object (readonly)
Returns the value of attribute object_functions.
6 7 8 |
# File 'lib/rvm/classes/class.rb', line 6 def object_functions @object_functions end |
#parent ⇒ Object
Returns the value of attribute parent.
11 12 13 |
# File 'lib/rvm/classes/class.rb', line 11 def parent @parent end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
9 10 11 |
# File 'lib/rvm/classes/class.rb', line 9 def variables @variables end |
Instance Method Details
#data_type ⇒ Object
13 14 15 |
# File 'lib/rvm/classes/class.rb', line 13 def data_type :class end |
#instance(params, env) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/rvm/classes/class.rb', line 39 def instance params, env o = RVM::Classes::Object.new self env = RVM::Interpreter::Environment.new({:params => params||[], :locals => @variables, :functions => @functions}, env) o.obj_send(@initializer, [], env) if @object_functions[@initializer] o end |
#obj_send(method, params, env) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rvm/classes/class.rb', line 26 def obj_send(method, params, env) if method == @initializer instance params, env else m = @functions[method] || m = @parent.functions(method) if not m and @parent raise "Unknown method #{method} for object #{self}" if not m params.unshift self env = RVM::Interpreter::Environment.new({:params => params||[], :locals => @variables, :functions => @functions}, env) m.call(params, env) end end |