Class: Dhallish::Context

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

Instance Method Summary collapse

Constructor Details

#initialize(outercontext = nil) ⇒ Context

Returns a new instance of Context.



369
370
371
372
# File 'lib/types.rb', line 369

def initialize(outercontext=nil)
	@outercontext = outercontext
	@scope = {}
end

Instance Method Details

#[](varname) ⇒ Object



374
375
376
377
378
379
380
381
# File 'lib/types.rb', line 374

def [](varname)
	val = @scope[varname]
	if val.nil? && !@outercontext.nil?
		@outercontext[varname]
	else
		val
	end
end

#[]=(varname, value) ⇒ Object



383
384
385
# File 'lib/types.rb', line 383

def []=(varname, value)
	@scope[varname] = value
end