Class: Dhall::Builtin

Inherits:
Expression show all
Defined in:
lib/dhall/builtins.rb

Instance Method Summary collapse

Methods inherited from Expression

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

Instance Method Details

#as_jsonObject



26
27
28
29
30
31
32
# File 'lib/dhall/builtins.rb', line 26

def as_json
	if (unfilled = unfill).class != self.class
		unfilled.as_json
	else
		self.class.name&.split(/::/)&.last&.tr("_", "/").to_s
	end
end

#call(*args) ⇒ Object



9
10
11
12
13
14
# File 'lib/dhall/builtins.rb', line 9

def call(*args)
	# Do not auto-normalize builtins to avoid recursion loop
	args.reduce(self) do |f, arg|
		Application.new(function: f, argument: arg)
	end
end

#unfillObject



16
17
18
19
20
21
22
23
24
# File 'lib/dhall/builtins.rb', line 16

def unfill
	attributes.reduce(self.class.new) do |f, attr|
		if send(attr.name).nil?
			f
		else
			Application.new(function: f, argument: send(attr.name))
		end
	end
end