Class: RVM::Interpreter::Block

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

Overview

A block localizes variables, do not mix this up with the RVM::Classes::Block class!

Blocks are mostly used to handle tasks as not interfeeing With outer code.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, pos = nil) ⇒ Block

Returns a new instance of Block.



226
227
228
229
# File 'lib/rvm/interpreter.rb', line 226

def initialize content, pos = nil
  @content = content
  @pos = pos
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



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

def content
  @content
end

Instance Method Details

#execute(env) ⇒ Object

When executed a temporary enviroment is created with the passed Enviroement as a parent to it. This new enviroment is discaded after the execution.



234
235
236
237
# File 'lib/rvm/interpreter.rb', line 234

def execute env
  tenv = Enviroment.new({}, env) 
  @content.execute tenv
end