Class: Dhall::Variable

Inherits:
Expression show all
Defined in:
lib/dhall/ast.rb,
lib/dhall/normalize.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#&, #*, #+, #as_dhall, #cache_key, #call, #concat, decode, #deep_merge, #deep_merge_type, #dhall_eq, #digest, #fetch, #fusion, #merge, #normalize, #resolve, #slice, #to_cbor, #to_proc, #|

Class Method Details

.[](name, index = 0) ⇒ Object



293
294
295
# File 'lib/dhall/ast.rb', line 293

def self.[](name, index=0)
	new(name: name, index: index)
end

Instance Method Details

#as_jsonObject



301
302
303
304
305
306
307
# File 'lib/dhall/ast.rb', line 301

def as_json
	if name == "_"
		index
	else
		[name, index]
	end
end

#shift(amount, name, min_index) ⇒ Object



138
139
140
141
142
# File 'lib/dhall/normalize.rb', line 138

def shift(amount, name, min_index)
	return self if self.name != name || min_index > index

	with(index: index + amount)
end

#substitute(var, with_expr) ⇒ Object



144
145
146
# File 'lib/dhall/normalize.rb', line 144

def substitute(var, with_expr)
	self == var ? with_expr : self
end

#to_sObject



297
298
299
# File 'lib/dhall/ast.rb', line 297

def to_s
	"#{name}@#{index}"
end