class RKelly::Runtime::ScopeChain
Public Class Methods
new(scope = Scope.new)
click to toggle source
# File lib/rkelly/runtime/scope_chain.rb, line 6 def initialize(scope = Scope.new) @chain = [GlobalObject.new] end
Public Instance Methods
<<(scope)
click to toggle source
# File lib/rkelly/runtime/scope_chain.rb, line 10 def <<(scope) @chain << scope end
[](name)
click to toggle source
# File lib/rkelly/runtime/scope_chain.rb, line 21 def [](name) property = has_property?(name) return property if property @chain.last.properties[name] end
[]=(name, value)
click to toggle source
# File lib/rkelly/runtime/scope_chain.rb, line 27 def []=(name, value) @chain.last.properties[name] = value end
has_property?(name)
click to toggle source
# File lib/rkelly/runtime/scope_chain.rb, line 14 def has_property?(name) scope = @chain.reverse.find { |x| x.has_property?(name) } scope ? scope[name] : nil end
new_scope() { |self| ... }
click to toggle source
# File lib/rkelly/runtime/scope_chain.rb, line 39 def new_scope(&block) @chain << Scope.new result = yield(self) @chain.pop result end
pop()
click to toggle source
# File lib/rkelly/runtime/scope_chain.rb, line 31 def pop @chain.pop end
return()
click to toggle source
# File lib/rkelly/runtime/scope_chain.rb, line 50 def return; @chain.last.return; end
return=(value)
click to toggle source
# File lib/rkelly/runtime/scope_chain.rb, line 46 def return=(value) @chain.last.return = value end
returned?()
click to toggle source
# File lib/rkelly/runtime/scope_chain.rb, line 52 def returned? @chain.last.returned? end
this()
click to toggle source
# File lib/rkelly/runtime/scope_chain.rb, line 35 def this @chain.last end