Class: Brandish::Execute Private

Inherits:
Object
  • Object
show all
Defined in:
lib/brandish/execute.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Executes a string of code in the instance of the class.

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Execute

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize the execution context.

Parameters:

  • context ({::Symbol, ::String => ::Object})

    The context. The keys are set as instance variables on the class, with the values being the instance variable's respective value.



14
15
16
# File 'lib/brandish/execute.rb', line 14

def initialize(context)
  context.each { |k, v| instance_variable_set(:"@#{k}", v) }
end

Instance Method Details

#exec(code) ⇒ ::Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Executes the given code in the context of the class.

Parameters:

  • code (::String)

    The code to execute.

Returns:

  • (::Object)


22
23
24
# File 'lib/brandish/execute.rb', line 22

def exec(code)
  instance_exec(code)
end