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

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

Class Method Details

.as_dhallObject



282
283
284
# File 'lib/dhall/ast.rb', line 282

def self.as_dhall
	Builtins[:Bool]
end

Instance Method Details

#!@Object



266
267
268
# File 'lib/dhall/ast.rb', line 266

def !@
	with(value: !value)
end

#&(other) ⇒ Object



250
251
252
# File 'lib/dhall/ast.rb', line 250

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

#===(other) ⇒ Object



270
271
272
# File 'lib/dhall/ast.rb', line 270

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

#as_jsonObject



278
279
280
# File 'lib/dhall/ast.rb', line 278

def as_json
	value
end

#dhall_eq(other) ⇒ Object



258
259
260
261
262
263
264
# File 'lib/dhall/ast.rb', line 258

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



246
247
248
# File 'lib/dhall/ast.rb', line 246

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

#to_sObject



274
275
276
# File 'lib/dhall/ast.rb', line 274

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

#|(other) ⇒ Object



254
255
256
# File 'lib/dhall/ast.rb', line 254

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