Class: RVM::Classes::Block

Inherits:
Class
  • Object
show all
Defined in:
lib/rvm/classes/block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Class

#data_type, #functions, #is_true?, #method_missing, #method_missing_old_class, #variables

Methods included from Plugin

#helper, #included, #plugin_host, #plugin_id, #register_for

Constructor Details

#initialize(code) ⇒ Block

Returns a new instance of Block.



6
7
8
9
10
# File 'lib/rvm/classes/block.rb', line 6

def initialize code
  super()
  @type = :any
  @code = code
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RVM::Classes::Class

Instance Attribute Details

#codeObject

Returns the value of attribute code.



4
5
6
# File 'lib/rvm/classes/block.rb', line 4

def code
  @code
end

Instance Method Details

#call(params, env, pos = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rvm/classes/block.rb', line 19

def call params, env, pos = nil
  RVM::debug "Calling Block at #{pos}...(#{env},#{params})" if $DEBUG
  env = RVM::Interpreter::Enviroment.new({:params => params||[]}, env)
  begin
    @code.execute(env)
  rescue RVM::Interpreter::ReturnException => e
    RVM::debug "yuck, cought a result!" if $DEBUG
    pp e if $DEBUG
    return e.val
  end
end

#execargsObject



15
16
17
# File 'lib/rvm/classes/block.rb', line 15

def execargs
  true
end

#execute(env) ⇒ Object



12
13
# File 'lib/rvm/classes/block.rb', line 12

def execute env
end