Class: Dhall::Import::EnvironmentVariable

Inherits:
Object
  • Object
show all
Defined in:
lib/dhall/ast.rb,
lib/dhall/binary.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(var) ⇒ EnvironmentVariable

Returns a new instance of EnvironmentVariable.



1591
1592
1593
# File 'lib/dhall/ast.rb', line 1591

def initialize(var)
	@var = var
end

Instance Attribute Details

#varObject (readonly)

Returns the value of attribute var.



1589
1590
1591
# File 'lib/dhall/ast.rb', line 1589

def var
  @var
end

Class Method Details

.decode(*args) ⇒ Object



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

def self.decode(*args)
	new(*args)
end

Instance Method Details

#as_jsonObject



1647
1648
1649
# File 'lib/dhall/ast.rb', line 1647

def as_json
	@var
end

#canonicalObject



1611
1612
1613
# File 'lib/dhall/ast.rb', line 1611

def canonical
	self
end

#chain_onto(relative_to) ⇒ Object



1595
1596
1597
1598
1599
1600
1601
# File 'lib/dhall/ast.rb', line 1595

def chain_onto(relative_to)
	if relative_to.is_a?(URI)
		raise ImportBannedException, "remote import cannot import #{self}"
	end

	self
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


1642
1643
1644
# File 'lib/dhall/ast.rb', line 1642

def eql?(other)
	other.is_a?(self.class) && other.var == var
end

#hashObject



1638
1639
1640
# File 'lib/dhall/ast.rb', line 1638

def hash
	@var.hash
end

#locationObject



1634
1635
1636
# File 'lib/dhall/ast.rb', line 1634

def location
	Union.from(Location, "Environment", to_s.as_dhall)
end

#originObject



1623
1624
1625
# File 'lib/dhall/ast.rb', line 1623

def origin
	"localhost"
end

#pathObject



1603
1604
1605
# File 'lib/dhall/ast.rb', line 1603

def path
	[]
end

#real_pathObject



1615
1616
1617
# File 'lib/dhall/ast.rb', line 1615

def real_path
	self
end

#resolve(resolver) ⇒ Object



1619
1620
1621
# File 'lib/dhall/ast.rb', line 1619

def resolve(resolver)
	resolver.resolve_environment(self)
end

#to_sObject



1627
1628
1629
1630
1631
1632
# File 'lib/dhall/ast.rb', line 1627

def to_s
	escapes = Parser::PosixEnvironmentVariableCharacter::ESCAPES
	"env:#{@var.gsub(/[\"\\\a\b\f\n\r\t\v]/) do |c|
		"\\" + escapes.find { |(_, v)| v == c }.first
	end}"
end

#with(path:) ⇒ Object



1607
1608
1609
# File 'lib/dhall/ast.rb', line 1607

def with(path:)
	Path.from_string(path.join("/"))
end