Class: Pbmenv::DirectoryObject

Inherits:
Object
  • Object
show all
Defined in:
lib/pbmenv/directory_object.rb

Defined Under Namespace

Classes: NonSymlinkError

Instance Method Summary collapse

Constructor Details

#initialize(path:) ⇒ DirectoryObject

Returns a new instance of DirectoryObject.



5
6
7
# File 'lib/pbmenv/directory_object.rb', line 5

def initialize(path: )
  @path = path
end

Instance Method Details

#pathObject



9
10
11
# File 'lib/pbmenv/directory_object.rb', line 9

def path
  @path
end

Returns:

  • (String, NilClass)


20
21
22
23
24
# File 'lib/pbmenv/directory_object.rb', line 20

def readlink
  readlink!
rescue NonSymlinkError
  nil
end

#readlink!String

Returns:

  • (String)

Raises:



14
15
16
17
# File 'lib/pbmenv/directory_object.rb', line 14

def readlink!
  raise NonSymlinkError if not symlink?
  File.readlink(path)
end