Class: Dhall::Import::EnvironmentVariable

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(var) ⇒ EnvironmentVariable

Returns a new instance of EnvironmentVariable.



1433
1434
1435
# File 'lib/dhall/ast.rb', line 1433

def initialize(var)
  @var = var
end

Instance Attribute Details

#varObject (readonly)

Returns the value of attribute var.



1431
1432
1433
# File 'lib/dhall/ast.rb', line 1431

def var
  @var
end

Instance Method Details

#as_jsonObject



1485
1486
1487
# File 'lib/dhall/ast.rb', line 1485

def as_json
  @var
end

#canonicalObject



1453
1454
1455
# File 'lib/dhall/ast.rb', line 1453

def canonical
  self
end

#chain_onto(relative_to) ⇒ Object



1437
1438
1439
1440
1441
1442
1443
# File 'lib/dhall/ast.rb', line 1437

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

  self
end

#hashObject



1476
1477
1478
# File 'lib/dhall/ast.rb', line 1476

def hash
  @var.hash
end

#originObject



1465
1466
1467
# File 'lib/dhall/ast.rb', line 1465

def origin
  "localhost"
end

#pathObject



1445
1446
1447
# File 'lib/dhall/ast.rb', line 1445

def path
  []
end

#real_pathObject



1457
1458
1459
# File 'lib/dhall/ast.rb', line 1457

def real_path
  self
end

#resolve(resolver) ⇒ Object



1461
1462
1463
# File 'lib/dhall/ast.rb', line 1461

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

#to_sObject



1469
1470
1471
1472
1473
1474
# File 'lib/dhall/ast.rb', line 1469

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



1449
1450
1451
# File 'lib/dhall/ast.rb', line 1449

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