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, ]
- VERSION =
'0.8.2'
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#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.
24 25 26 27 28 29 30 |
# File 'lib/transparent_lua.rb', line 24 def initialize(sandbox, = {}) @sandbox = sandbox @state = .fetch(:state) { Lua::State.new } @logger = .fetch(:logger) { Logger.new('/dev/null') } leak_locals = .fetch(:leak_globals) { false } setup(leak_locals) end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
16 17 18 |
# File 'lib/transparent_lua.rb', line 16 def logger @logger end |
#sandbox ⇒ Object (readonly)
Returns the value of attribute sandbox.
16 17 18 |
# File 'lib/transparent_lua.rb', line 16 def sandbox @sandbox end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
16 17 18 |
# File 'lib/transparent_lua.rb', line 16 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 |