Class: RubyRunJs::LocalScope
- Inherits:
-
Object
- Object
- RubyRunJs::LocalScope
- 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
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(parent, builtin) ⇒ LocalScope
constructor
A new instance of LocalScope.
- #set_binding(var_label, var_value, throw = false) ⇒ Object
Methods included from ScopeHelper
#create_and_set_binding, #create_bindings
Constructor Details
#initialize(parent, builtin) ⇒ LocalScope
Returns a new instance of LocalScope.
68 69 70 71 72 73 |
# File 'lib/ruby_run_js/scope.rb', line 68 def initialize(parent, builtin) @own = {} @parent = parent @stack = [] @builtin = builtin end |
Instance Attribute Details
#builtin ⇒ Object (readonly)
Returns the value of attribute builtin.
65 66 67 |
# File 'lib/ruby_run_js/scope.rb', line 65 def builtin @builtin end |
#own ⇒ Object (readonly)
Returns the value of attribute own.
65 66 67 |
# File 'lib/ruby_run_js/scope.rb', line 65 def own @own end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
65 66 67 |
# File 'lib/ruby_run_js/scope.rb', line 65 def stack @stack end |
#this_binding ⇒ Object
Returns the value of attribute this_binding.
66 67 68 |
# File 'lib/ruby_run_js/scope.rb', line 66 def this_binding @this_binding end |
Instance Method Details
#create_binding(var_label) ⇒ Object
79 80 81 82 83 |
# File 'lib/ruby_run_js/scope.rb', line 79 def create_binding(var_label) unless @own.key?(var_label) @own[var_label] = undefined end end |
#delete_binding(var_label) ⇒ Object
97 98 99 |
# File 'lib/ruby_run_js/scope.rb', line 97 def delete_binding(var_label) @own.key?(var_label) ? @own.delete(var_label) : @parent.delete_binding(var_label) end |
#get_binding_value(var_label, throw = false) ⇒ Object
93 94 95 |
# File 'lib/ruby_run_js/scope.rb', line 93 def get_binding_value(var_label,throw = false) @own.key?(var_label) ? @own[var_label] : @parent.get_binding_value(var_label,throw) end |
#has_binding(var_label) ⇒ Object
75 76 77 |
# File 'lib/ruby_run_js/scope.rb', line 75 def has_binding(var_label) @own.key?(var_label) end |
#set_binding(var_label, var_value, throw = false) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/ruby_run_js/scope.rb', line 85 def set_binding(var_label,var_value,throw = false) if @own.key?(var_label) @own[var_label] = var_label else @parent.set_binding(var_label,var_value,throw) end end |