Class: RubyRunJs::ObjectScope
- Inherits:
-
Object
- Object
- RubyRunJs::ObjectScope
- Includes:
- ScopeHelper
- Defined in:
- lib/ruby_run_js/scope.rb
Instance Attribute Summary collapse
-
#builtin ⇒ Object
readonly
Returns the value of attribute builtin.
-
#own ⇒ Object
readonly
Returns the value of attribute own.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
-
#this_binding ⇒ Object
readonly
Returns the value of attribute this_binding.
Instance Method Summary collapse
- #create_binding(var_label) ⇒ Object
- #delete_binding(var_label) ⇒ Object
- #get_binding_value(var_label, throw = false) ⇒ Object
- #has_binding(var_label) ⇒ Object
-
#initialize(obj, parent, builtin) ⇒ ObjectScope
constructor
A new instance of ObjectScope.
- #set_binding(var_label, var_value, throw = false) ⇒ Object
Methods included from ScopeHelper
#create_and_set_binding, #create_bindings
Constructor Details
#initialize(obj, parent, builtin) ⇒ ObjectScope
Returns a new instance of ObjectScope.
107 108 109 110 111 112 |
# File 'lib/ruby_run_js/scope.rb', line 107 def initialize(obj, parent, builtin) @own = obj @parent = parent @stack = [] @builtin = builtin end |
Instance Attribute Details
#builtin ⇒ Object (readonly)
Returns the value of attribute builtin.
105 106 107 |
# File 'lib/ruby_run_js/scope.rb', line 105 def builtin @builtin end |
#own ⇒ Object (readonly)
Returns the value of attribute own.
105 106 107 |
# File 'lib/ruby_run_js/scope.rb', line 105 def own @own end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
105 106 107 |
# File 'lib/ruby_run_js/scope.rb', line 105 def stack @stack end |
#this_binding ⇒ Object (readonly)
Returns the value of attribute this_binding.
105 106 107 |
# File 'lib/ruby_run_js/scope.rb', line 105 def this_binding @this_binding end |
Instance Method Details
#create_binding(var_label) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/ruby_run_js/scope.rb', line 118 def create_binding(var_label) unless @own.has_binding(var_label) @own.define_own_property(var_label, { 'value' => undefined, 'configurable' => false, 'writable' => true, 'enumerable' => true },false) end end |
#delete_binding(var_label) ⇒ Object
142 143 144 |
# File 'lib/ruby_run_js/scope.rb', line 142 def delete_binding(var_label) @own.key?(var_label) ? @own.delete(var_label, false) : @parent.delete_binding(var_label) end |
#get_binding_value(var_label, throw = false) ⇒ Object
138 139 140 |
# File 'lib/ruby_run_js/scope.rb', line 138 def get_binding_value(var_label,throw = false) @own.key?(var_label) ? @own.get(var_label, throw) : @parent.get_binding_value(var_label, throw) end |
#has_binding(var_label) ⇒ Object
114 115 116 |
# File 'lib/ruby_run_js/scope.rb', line 114 def has_binding(var_label) @own.has_binding(var_label) end |
#set_binding(var_label, var_value, throw = false) ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/ruby_run_js/scope.rb', line 130 def set_binding(var_label,var_value,throw = false) if @own.key?(var_label) @own.put(var_label, var_value, throw) else @parent.set_binding(var_label,var_value,throw) end end |