Class: RVM::Interpreter::Block
- 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
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Attributes inherited from Element
Instance Method Summary collapse
-
#execute(env) ⇒ Object
When executed a temporary environment is created with the passed Enviroement as a parent to it.
-
#initialize(content, pos = nil) ⇒ Block
constructor
A new instance of Block.
- #optimize ⇒ Object
- #pretty_print(q) ⇒ Object
Constructor Details
#initialize(content, pos = nil) ⇒ Block
Returns a new instance of Block.
174 175 176 177 |
# File 'lib/rvm/interpreter.rb', line 174 def initialize content, pos = nil super(pos) @content = content end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
173 174 175 |
# File 'lib/rvm/interpreter.rb', line 173 def content @content end |
Instance Method Details
#execute(env) ⇒ Object
When executed a temporary environment is created with the passed Enviroement as a parent to it. This new environment is discaded after the execution.
189 190 191 192 |
# File 'lib/rvm/interpreter.rb', line 189 def execute env tenv = Environment.new({}, env) @content.execute tenv end |
#optimize ⇒ Object
194 195 196 197 |
# File 'lib/rvm/interpreter.rb', line 194 def optimize @content = @content.optimize super end |
#pretty_print(q) ⇒ Object
179 180 181 182 183 184 |
# File 'lib/rvm/interpreter.rb', line 179 def pretty_print(q) first = true q.group 1, "{", "}" do q.pp @content end end |