Class: Dhall::Builtins::Text_show

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

Constant Summary collapse

ENCODE =
(Hash.new { |_, x| "\\u%04x" % x.ord }).merge(
	"\"" => "\\\"",
	"\\" => "\\\\",
	"\b" => "\\b",
	"\f" => "\\f",
	"\n" => "\\n",
	"\r" => "\\r",
	"\t" => "\\t"
)

Instance Method Summary collapse

Methods inherited from Dhall::Builtin

#as_json, #unfill

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

#call(arg) ⇒ Object



407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/dhall/builtins.rb', line 407

def call(arg)
	if arg.is_a?(Dhall::Text)
		Dhall::Text.new(
			value: "\"#{arg.value.gsub(
				/["\$\\\b\f\n\r\t\u0000-\u001F]/,
				&ENCODE
			)}\""
		)
	else
		super
	end
end