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.



1541
1542
1543
# File 'lib/dhall/ast.rb', line 1541

def initialize(var)
  @var = var
end

Instance Attribute Details

#varObject (readonly)

Returns the value of attribute var.



1539
1540
1541
# File 'lib/dhall/ast.rb', line 1539

def var
  @var
end

Class Method Details

.decode(*args) ⇒ Object



248
249
250
# File 'lib/dhall/binary.rb', line 248

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

Instance Method Details

#as_jsonObject



1597
1598
1599
# File 'lib/dhall/ast.rb', line 1597

def as_json
  @var
end

#canonicalObject



1561
1562
1563
# File 'lib/dhall/ast.rb', line 1561

def canonical
  self
end

#chain_onto(relative_to) ⇒ Object



1545
1546
1547
1548
1549
1550
1551
# File 'lib/dhall/ast.rb', line 1545

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)


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

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

#hashObject



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

def hash
  @var.hash
end

#locationObject



1584
1585
1586
# File 'lib/dhall/ast.rb', line 1584

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

#originObject



1573
1574
1575
# File 'lib/dhall/ast.rb', line 1573

def origin
  "localhost"
end

#pathObject



1553
1554
1555
# File 'lib/dhall/ast.rb', line 1553

def path
  []
end

#real_pathObject



1565
1566
1567
# File 'lib/dhall/ast.rb', line 1565

def real_path
  self
end

#resolve(resolver) ⇒ Object



1569
1570
1571
# File 'lib/dhall/ast.rb', line 1569

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

#to_sObject



1577
1578
1579
1580
1581
1582
# File 'lib/dhall/ast.rb', line 1577

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



1557
1558
1559
# File 'lib/dhall/ast.rb', line 1557

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