Class: TransparentLua
- Inherits:
-
Object
- Object
- TransparentLua
- Defined in:
- lib/transparent_lua.rb,
lib/transparent_lua/version.rb
Constant Summary collapse
- SUPPORTED_SIMPLE_DATATYPES =
[ NilClass, TrueClass, FalseClass, Fixnum, Bignum, Float, Proc, String, Hash, Array, ]
- VERSION =
0.6
Instance Attribute Summary collapse
-
#sandbox ⇒ Object
readonly
Returns the value of attribute sandbox.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
-
#call(script, script_name = nil) ⇒ Object
The return value of the lua script.
-
#initialize(sandbox, options = {}) ⇒ TransparentLua
constructor
A new instance of TransparentLua.
Constructor Details
#initialize(sandbox, options = {}) ⇒ TransparentLua
Returns a new instance of TransparentLua.
25 26 27 28 29 30 |
# File 'lib/transparent_lua.rb', line 25 def initialize(sandbox, = {}) @sandbox = sandbox @state = .fetch(:state) { Lua::State.new } leak_locals = .fetch(:leak_globals) { false } setup(leak_locals) end |
Instance Attribute Details
#sandbox ⇒ Object (readonly)
Returns the value of attribute sandbox.
17 18 19 |
# File 'lib/transparent_lua.rb', line 17 def sandbox @sandbox end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
17 18 19 |
# File 'lib/transparent_lua.rb', line 17 def state @state end |
Instance Method Details
#call(script, script_name = nil) ⇒ Object
Returns the return value of the lua script.
35 36 37 38 |
# File 'lib/transparent_lua.rb', line 35 def call(script, script_name = nil) v = state.__eval(script, script_name) lua2rb(v) end |