Class: Rhino::Context
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Class Method Summary collapse
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
- #eval(str) ⇒ Object
-
#initialize(native, options) ⇒ Context
constructor
:nodoc:.
- #instruction_limit=(limit) ⇒ Object
Constructor Details
#initialize(native, options) ⇒ Context
:nodoc:
20 21 22 23 24 25 26 27 28 |
# File 'lib/rhino/context.rb', line 20 def initialize(native, ) #:nodoc: @native = native @scope = NativeObject.new(@native.initStandardObjects(nil, [:sealed] == true)) unless [:java] for package in ["Packages", "java", "org", "com"] @scope.j.delete(package) end end end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
8 9 10 |
# File 'lib/rhino/context.rb', line 8 def scope @scope end |
Class Method Details
.open(options = {}) ⇒ Object
11 12 13 14 15 |
# File 'lib/rhino/context.rb', line 11 def open( = {}) ContextFactory.new.call do |native| yield new(native, ) end end |
Instance Method Details
#[](k) ⇒ Object
30 31 32 |
# File 'lib/rhino/context.rb', line 30 def [](k) @scope[k] end |
#[]=(k, v) ⇒ Object
34 35 36 |
# File 'lib/rhino/context.rb', line 34 def []=(k,v) @scope[k] = v end |
#eval(str) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/rhino/context.rb', line 38 def eval(str) str = str.to_s begin To.ruby @native.evaluateString(@scope.j, str, "<eval>", 1, nil) rescue J::RhinoException => e raise Rhino::RhinoError, e end end |
#instruction_limit=(limit) ⇒ Object
47 48 49 50 |
# File 'lib/rhino/context.rb', line 47 def instruction_limit=(limit) @native.setInstructionObserverThreshold(limit); @native.factory.instruction_limit = limit end |