Class: Nydp::ContextSymbol
- Inherits:
-
Object
- Object
- Nydp::ContextSymbol
- Defined in:
- lib/nydp/context_symbol.rb
Instance Attribute Summary collapse
-
#depth ⇒ Object
Returns the value of attribute depth.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #assign(value, context) ⇒ Object
-
#initialize(depth, name) ⇒ ContextSymbol
constructor
A new instance of ContextSymbol.
- #inspect ⇒ Object
- #to_s ⇒ Object
- #value(context) ⇒ Object
Constructor Details
#initialize(depth, name) ⇒ ContextSymbol
Returns a new instance of ContextSymbol.
5 6 7 |
# File 'lib/nydp/context_symbol.rb', line 5 def initialize depth, name @depth, @name = depth, name end |
Instance Attribute Details
#depth ⇒ Object
Returns the value of attribute depth.
3 4 5 |
# File 'lib/nydp/context_symbol.rb', line 3 def depth @depth end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/nydp/context_symbol.rb', line 3 def name @name end |
Instance Method Details
#assign(value, context) ⇒ Object
13 14 15 |
# File 'lib/nydp/context_symbol.rb', line 13 def assign value, context context.nth(depth).set(name, value) end |
#inspect ⇒ Object
17 |
# File 'lib/nydp/context_symbol.rb', line 17 def inspect; to_s; end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/nydp/context_symbol.rb', line 18 def to_s "[#{depth}]#{name}" end |
#value(context) ⇒ Object
9 10 11 |
# File 'lib/nydp/context_symbol.rb', line 9 def value context context.nth(depth).at(name) end |