Class: Rufus::Lua::State

Inherits:
Object
  • Object
show all
Defined in:
lib/immunio/rufus_lua_ext/state.rb

Instance Method Summary collapse

Instance Method Details

#load(code, filename = nil) ⇒ Object

Load the code into a function and return it. Safer than evaling some string.



5
6
7
8
9
10
11
12
13
# File 'lib/immunio/rufus_lua_ext/state.rb', line 5

def load(code, filename=nil)
  err = Lib.luaL_loadbuffer(@pointer, code, code.size, filename)
  fail_if_error('load:compile', err, nil, filename, nil)

  function = stack_fetch
  stack_pop

  function
end