Class: Nydp::ContextSymbol

Inherits:
Object
  • Object
show all
Defined in:
lib/nydp/context_symbol.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#depthObject

Returns the value of attribute depth.



3
4
5
# File 'lib/nydp/context_symbol.rb', line 3

def depth
  @depth
end

#nameObject

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

#inspectObject



17
# File 'lib/nydp/context_symbol.rb', line 17

def inspect; to_s; end

#to_sObject



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