Class: CommonjsRhino::Context
- Inherits:
-
Object
- Object
- CommonjsRhino::Context
- Defined in:
- lib/commonjs-rhino.rb
Instance Attribute Summary collapse
-
#require_base_paths ⇒ Object
readonly
Returns the value of attribute require_base_paths.
-
#rhino_context ⇒ Object
readonly
Returns the value of attribute rhino_context.
-
#shared_scope ⇒ Object
readonly
Returns the value of attribute shared_scope.
Instance Method Summary collapse
- #eval(str) ⇒ Object
- #eval_file(file) ⇒ Object
-
#initialize(shared_scope, require_base_paths) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(shared_scope, require_base_paths) ⇒ Context
Returns a new instance of Context.
18 19 20 21 22 |
# File 'lib/commonjs-rhino.rb', line 18 def initialize(shared_scope, require_base_paths) @shared_scope = shared_scope @require_base_paths = require_base_paths nil end |
Instance Attribute Details
#require_base_paths ⇒ Object (readonly)
Returns the value of attribute require_base_paths.
16 17 18 |
# File 'lib/commonjs-rhino.rb', line 16 def require_base_paths @require_base_paths end |
#rhino_context ⇒ Object (readonly)
Returns the value of attribute rhino_context.
16 17 18 |
# File 'lib/commonjs-rhino.rb', line 16 def rhino_context @rhino_context end |
#shared_scope ⇒ Object (readonly)
Returns the value of attribute shared_scope.
16 17 18 |
# File 'lib/commonjs-rhino.rb', line 16 def shared_scope @shared_scope end |
Instance Method Details
#eval(str) ⇒ Object
32 33 34 35 36 |
# File 'lib/commonjs-rhino.rb', line 32 def eval(str) with_context do |context| context.evaluateString(shared_scope, str, nil, 1, nil) end end |
#eval_file(file) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/commonjs-rhino.rb', line 24 def eval_file(file) with_context do |context| context.evaluateReader( shared_scope, FileReader.new(file), nil, 1, nil ) end end |