Class: Teacher::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/teacher/scope.rb

Direct Known Subclasses

TopLevel

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent = nil) ⇒ Scope

Returns a new instance of Scope.



6
7
8
9
10
# File 'lib/teacher/scope.rb', line 6

def initialize(parent = nil)
  @parent = parent || {}
  @symbols = {}
  @published_variables = {}
end

Instance Attribute Details

#published_variablesObject (readonly)

Returns the value of attribute published_variables.



4
5
6
# File 'lib/teacher/scope.rb', line 4

def published_variables
  @published_variables
end

#symbolsObject (readonly)

Returns the value of attribute symbols.



4
5
6
# File 'lib/teacher/scope.rb', line 4

def symbols
  @symbols
end

Instance Method Details

#[](name) ⇒ Object



12
13
14
# File 'lib/teacher/scope.rb', line 12

def [](name)
  @symbols[name] || @parent[name]
end

#[]=(name, value) ⇒ Object



16
17
18
# File 'lib/teacher/scope.rb', line 16

def []=(name, value)
  @symbols[name] = value
end