class Git::Path

A base class that represents and validates a filesystem path

Use for tracking things relevant to a Git repository, such as the working directory or index file.

Attributes

path[RW]

Public Class Methods

new(path, must_exist: true) click to toggle source
# File lib/git/path.rb, line 12
def initialize(path, must_exist: true)
  path = File.expand_path(path)

  raise ArgumentError, 'path does not exist', [path] if must_exist && !File.exist?(path)

  @path = path
end

Public Instance Methods

readable?() click to toggle source
# File lib/git/path.rb, line 20
def readable?
  File.readable?(@path)
end
to_s() click to toggle source
# File lib/git/path.rb, line 28
def to_s
  @path
end
writable?() click to toggle source
# File lib/git/path.rb, line 24
def writable?
  File.writable?(@path)
end