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?

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.



216
217
218
219
220
221
# File 'lib/rvm/interpreter.rb', line 216

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

Instance Method Details

#execute(env) ⇒ Object



223
224
225
226
# File 'lib/rvm/interpreter.rb', line 223

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