Class: Teacher::Scope
- Inherits:
-
Object
- Object
- Teacher::Scope
- Defined in:
- lib/teacher/scope.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#published_variables ⇒ Object
readonly
Returns the value of attribute published_variables.
-
#symbols ⇒ Object
readonly
Returns the value of attribute symbols.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
-
#initialize(parent = nil) ⇒ Scope
constructor
A new instance of Scope.
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_variables ⇒ Object (readonly)
Returns the value of attribute published_variables.
4 5 6 |
# File 'lib/teacher/scope.rb', line 4 def published_variables @published_variables end |
#symbols ⇒ Object (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 |