Class: RubyRunJs::GlobalScope
- Inherits:
-
JsBaseObject
- Object
- JsBaseObject
- RubyRunJs::GlobalScope
- Includes:
- ScopeHelper
- Defined in:
- lib/ruby_run_js/scope.rb
Instance Attribute Summary collapse
-
#builtin ⇒ Object
readonly
Returns the value of attribute builtin.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
-
#this_binding ⇒ Object
Returns the value of attribute this_binding.
Attributes inherited from JsBaseObject
#extensible, #own, #prototype, #value
Instance Method Summary collapse
- #_class ⇒ Object
- #create_binding(var_label) ⇒ Object
- #get_binding_value(var_label, throw = false) ⇒ Object
-
#initialize(builtin) ⇒ GlobalScope
constructor
A new instance of GlobalScope.
Methods included from ScopeHelper
#create_and_set_binding, #create_bindings
Methods inherited from JsBaseObject
#_type, #can_put, #default_value, #define_own_property, #delete, #get, #get_items, #get_own_property, #get_property, #has_property, #put, #set_items
Methods included from Helper
#check_object, #get_member, #get_member_dot, #is_accessor_descriptor, #is_callable, #is_data_descriptor, #is_generic_descriptor, #is_primitive, #make_error, #strict_equality
Methods included from ConversionHelper
#convert_to_js_type, #to_boolean, #to_int32, #to_integer, #to_number, #to_object, #to_primitive, #to_string, #to_uint16, #to_uint32
Constructor Details
#initialize(builtin) ⇒ GlobalScope
Returns a new instance of GlobalScope.
26 27 28 29 30 |
# File 'lib/ruby_run_js/scope.rb', line 26 def initialize(builtin) super() @stack = [] @builtin = builtin end |
Instance Attribute Details
#builtin ⇒ Object (readonly)
Returns the value of attribute builtin.
23 24 25 |
# File 'lib/ruby_run_js/scope.rb', line 23 def builtin @builtin end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
23 24 25 |
# File 'lib/ruby_run_js/scope.rb', line 23 def stack @stack end |
#this_binding ⇒ Object
Returns the value of attribute this_binding.
24 25 26 |
# File 'lib/ruby_run_js/scope.rb', line 24 def this_binding @this_binding end |
Instance Method Details
#_class ⇒ Object
32 33 34 |
# File 'lib/ruby_run_js/scope.rb', line 32 def _class 'Global' end |
#create_binding(var_label) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ruby_run_js/scope.rb', line 36 def create_binding(var_label) unless has_binding(var_label) define_own_property(var_label, { 'value' => undefined, 'configurable' => false, 'writable' => true, 'enumerable' => true },false) end end |
#get_binding_value(var_label, throw = false) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/ruby_run_js/scope.rb', line 48 def get_binding_value(var_label, throw = false) if !has_binding(var_label) && throw raise make_error('ReferenceError', "#{var_label} is not defined") end get(var_label) end |