Sha256: 224c49e416487250117ea9bbbbe3449d04b20fe1c48e60e84ef27e35a29b1c43

Contents?: true

Size: 505 Bytes

Versions: 3

Compression:

Stored size: 505 Bytes

Contents

module Pbmenv
  class DirectoryObject
    class NonSymlinkError < StandardError; end

    def initialize(path: )
      @path = path
    end

    def path
      @path
    end

    # @return [String]
    def readlink!
      raise NonSymlinkError if not symlink?
      File.readlink(path)
    end

    # @return [String, NilClass]
    def readlink
      readlink!
    rescue NonSymlinkError
      nil
    end

    private

    # @return [Boolean]
    def symlink?
      File.symlink?(path)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pbmenv-0.1.13 lib/pbmenv/directory_object.rb
pbmenv-0.1.12 lib/pbmenv/directory_object.rb
pbmenv-0.1.11 lib/pbmenv/directory_object.rb