Class: Dhall::Bool

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Expression

#*, #+, #annotate, #as_dhall, #cache_key, #call, #concat, decode, #deep_merge, #deep_merge_type, #digest, #fetch, #fusion, #merge, #normalize, #resolve, #shift, #slice, #substitute, #to_binary, #to_cbor, #to_proc

Class Method Details

.as_dhallObject



316
317
318
# File 'lib/dhall/ast.rb', line 316

def self.as_dhall
	Builtins[:Bool]
end

Instance Method Details

#!@Object



300
301
302
# File 'lib/dhall/ast.rb', line 300

def !@
	with(value: !value)
end

#&(other) ⇒ Object



284
285
286
# File 'lib/dhall/ast.rb', line 284

def &(other)
	reduce(other, with(value: false))
end

#===(other) ⇒ Object



304
305
306
# File 'lib/dhall/ast.rb', line 304

def ===(other)
	self == other || value === other
end

#as_jsonObject



312
313
314
# File 'lib/dhall/ast.rb', line 312

def as_json
	value
end

#dhall_eq(other) ⇒ Object



292
293
294
295
296
297
298
# File 'lib/dhall/ast.rb', line 292

def dhall_eq(other)
	if other.is_a?(Bool)
		reduce(other, with(value: self == other))
	else
		reduce(other, super)
	end
end

#reduce(when_true, when_false) ⇒ Object



280
281
282
# File 'lib/dhall/ast.rb', line 280

def reduce(when_true, when_false)
	value ? when_true : when_false
end

#to_sObject



308
309
310
# File 'lib/dhall/ast.rb', line 308

def to_s
	reduce("True", "False")
end

#|(other) ⇒ Object



288
289
290
# File 'lib/dhall/ast.rb', line 288

def |(other)
	reduce(with(value: true), other)
end