Class: Stamina::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/stamina-core/stamina/engine.rb,
lib/stamina-core/stamina/engine/context.rb

Defined Under Namespace

Classes: Context

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEngine

Returns a new instance of Engine.



5
6
7
# File 'lib/stamina-core/stamina/engine.rb', line 5

def initialize
  extend(Stamina::Dsl)
end

Class Method Details

.execute(*args) ⇒ Object



27
28
29
# File 'lib/stamina-core/stamina/engine.rb', line 27

def self.execute(*args)
  new.execute(*args)
end

Instance Method Details

#execute(code, file = nil) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/stamina-core/stamina/engine.rb', line 13

def execute(code, file = nil)
  code = <<-EOF
    main = begin
      #{code}
    end
    Context.new(local_variables, binding)
  EOF
  if file
    eval(code, execute_binding, file)
  else
    eval(code, execute_binding)
  end
end

#execute_bindingObject



9
10
11
# File 'lib/stamina-core/stamina/engine.rb', line 9

def execute_binding
  binding
end