Class: Binding

Inherits:
Object show all
Defined in:
opal/opal/corelib/binding.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#receiverObject (readonly)

Returns the value of attribute receiver.



36
37
38
# File 'opal/opal/corelib/binding.rb', line 36

def receiver
  @receiver
end

#source_locationObject (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

Returns:



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_variablesObject



22
23
24
# File 'opal/opal/corelib/binding.rb', line 22

def local_variables
  @scope_variables
end