Class: RVM::Interpreter::SetClassFunction

Inherits:
Element
  • Object
show all
Defined in:
lib/rvm/interpreter.rb

Overview

This sets a funciton on a Class (to be included in its objects)

To define class functions use ObjectContext and define the function normaly, nifty isn’t it?

This object may be subject to removal or change, don’t use it yet.


TODO: Work this over.

Instance Attribute Summary

Attributes inherited from Element

#pos

Instance Method Summary collapse

Constructor Details

#initialize(obj, name, function, pos = nil) ⇒ SetClassFunction

Returns a new instance of SetClassFunction.



329
330
331
332
333
334
# File 'lib/rvm/interpreter.rb', line 329

def initialize obj, name, function, pos = nil
  super(pos)
  @object = obj
  @name = name
  @function = function
end

Instance Method Details

#execute(env) ⇒ Object



336
337
338
339
# File 'lib/rvm/interpreter.rb', line 336

def execute env
  @object.object_functions[@name.execute(env)] = @function
  @function
end