Class: Dhall::Import::Path

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*path) ⇒ Path

Returns a new instance of Path.



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

def initialize(*path)
  super(path: path)
end

Class Method Details

.decode(*args) ⇒ Object



242
243
244
# File 'lib/dhall/binary.rb', line 242

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

.from_string(s) ⇒ Object



1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
# File 'lib/dhall/ast.rb', line 1440

def self.from_string(s)
  prefix, *suffix = s.to_s.split(/\//)
  if prefix == ""
    AbsolutePath.new(*suffix)
  elsif prefix == "~"
    RelativeToHomePath.new(*suffix)
  elsif prefix == ".."
    RelativeToParentPath.new(*suffix)
  else
    RelativePath.new(prefix, *suffix)
  end
end

Instance Method Details

#as_jsonObject



1473
1474
1475
# File 'lib/dhall/ast.rb', line 1473

def as_json
  path
end

#canonicalObject



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

def canonical
  self.class.from_string(pathname.cleanpath)
end

#locationObject



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

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

#originObject



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

def origin
  "localhost"
end

#resolve(resolver) ⇒ Object



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

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

#to_sObject



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

def to_s
  pathname.to_s
end

#with(path:) ⇒ Object



1436
1437
1438
# File 'lib/dhall/ast.rb', line 1436

def with(path:)
  self.class.new(*path)
end