Class: Binding
Instance Attribute Summary collapse
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
-
#source_location ⇒ Object
readonly
Returns the value of attribute source_location.
Instance Method Summary collapse
- #eval(str, file = nil, line = nil) ⇒ Object
-
#initialize(jseval, scope_variables, receiver, source_location) ⇒ Binding
constructor
A new instance of Binding.
- #js_eval(*args) ⇒ Object
- #local_variable_defined?(value) ⇒ Boolean
- #local_variable_get(symbol) ⇒ Object
- #local_variable_set(symbol, value) ⇒ Object
- #local_variables ⇒ Object
Constructor Details
#initialize(jseval, scope_variables, receiver, source_location) ⇒ Binding
Returns a new instance of Binding.
3 4 5 6 |
# File 'opal/opal/corelib/binding.rb', line 3 def initialize(jseval, scope_variables, receiver, source_location) @jseval, @scope_variables, @receiver, @source_location = \ jseval, scope_variables, receiver, source_location end |
Instance Attribute Details
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
36 37 38 |
# File 'opal/opal/corelib/binding.rb', line 36 def receiver @receiver end |
#source_location ⇒ Object (readonly)
Returns the value of attribute source_location.
36 37 38 |
# File 'opal/opal/corelib/binding.rb', line 36 def source_location @source_location end |
Instance Method Details
#eval(str, file = nil, line = nil) ⇒ Object
30 31 32 33 34 |
# File 'opal/opal/corelib/binding.rb', line 30 def eval(str, file = nil, line = nil) return receiver if str == 'self' Kernel.eval(str, self, file, line) end |
#js_eval(*args) ⇒ Object
8 9 10 |
# File 'opal/opal/corelib/binding.rb', line 8 def js_eval(*args) @jseval.call(*args) end |
#local_variable_defined?(value) ⇒ Boolean
26 27 28 |
# File 'opal/opal/corelib/binding.rb', line 26 def local_variable_defined?(value) @scope_variables.include?(value) end |
#local_variable_get(symbol) ⇒ Object
12 13 14 15 16 |
# File 'opal/opal/corelib/binding.rb', line 12 def local_variable_get(symbol) js_eval(symbol) rescue Exception raise NameError, "local variable `#{symbol}' is not defined for #{inspect}" end |
#local_variable_set(symbol, value) ⇒ Object
18 19 20 |
# File 'opal/opal/corelib/binding.rb', line 18 def local_variable_set(symbol, value) js_eval(symbol, value) end |
#local_variables ⇒ Object
22 23 24 |
# File 'opal/opal/corelib/binding.rb', line 22 def local_variables @scope_variables end |