Class: Dhall::Import::Path

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*path) ⇒ Path

Returns a new instance of Path.



1332
1333
1334
# File 'lib/dhall/ast.rb', line 1332

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

Class Method Details

.from_string(s) ⇒ Object



1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
# File 'lib/dhall/ast.rb', line 1340

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



1369
1370
1371
# File 'lib/dhall/ast.rb', line 1369

def as_json
  path
end

#canonicalObject



1353
1354
1355
# File 'lib/dhall/ast.rb', line 1353

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

#originObject



1361
1362
1363
# File 'lib/dhall/ast.rb', line 1361

def origin
  "localhost"
end

#resolve(resolver) ⇒ Object



1357
1358
1359
# File 'lib/dhall/ast.rb', line 1357

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

#to_sObject



1365
1366
1367
# File 'lib/dhall/ast.rb', line 1365

def to_s
  pathname.to_s
end

#with(path:) ⇒ Object



1336
1337
1338
# File 'lib/dhall/ast.rb', line 1336

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