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.



1219
1220
1221
# File 'lib/dhall/ast.rb', line 1219

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

Class Method Details

.from_string(s) ⇒ Object



1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
# File 'lib/dhall/ast.rb', line 1227

def self.from_string(s)
  parts = s.to_s.split(/\//)
  if parts.first == ""
    AbsolutePath.new(*parts[1..-1])
  elsif parts.first == "~"
    RelativeToHomePath.new(*parts[1..-1])
  else
    RelativePath.new(*parts)
  end
end

Instance Method Details

#as_jsonObject



1254
1255
1256
# File 'lib/dhall/ast.rb', line 1254

def as_json
  path
end

#canonicalObject



1238
1239
1240
# File 'lib/dhall/ast.rb', line 1238

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

#originObject



1246
1247
1248
# File 'lib/dhall/ast.rb', line 1246

def origin
  "localhost"
end

#resolve(resolver) ⇒ Object



1242
1243
1244
# File 'lib/dhall/ast.rb', line 1242

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

#to_sObject



1250
1251
1252
# File 'lib/dhall/ast.rb', line 1250

def to_s
  pathname.to_s
end

#with(path:) ⇒ Object



1223
1224
1225
# File 'lib/dhall/ast.rb', line 1223

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