Class: Git::Path
- Inherits:
-
Object
- Object
- Git::Path
- Defined in:
- lib/git/path.rb
Overview
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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#path
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path, must_exist: true) ⇒ Path
constructor
A new instance of Path.
- #readable? ⇒ Boolean
- #to_s
- #writable? ⇒ Boolean
Constructor Details
#initialize(path, must_exist: true) ⇒ Path
Returns a new instance of Path.
12 13 14 15 16 17 18 |
# File 'lib/git/path.rb', line 12 def initialize(path, must_exist: true) path = File.(path) raise ArgumentError, 'path does not exist', [path] if must_exist && !File.exist?(path) @path = path end |
Instance Attribute Details
#path
Returns the value of attribute path.
10 11 12 |
# File 'lib/git/path.rb', line 10 def path @path end |
Instance Method Details
#readable? ⇒ Boolean
20 21 22 |
# File 'lib/git/path.rb', line 20 def readable? File.readable?(@path) end |
#to_s
28 29 30 |
# File 'lib/git/path.rb', line 28 def to_s @path end |
#writable? ⇒ Boolean
24 25 26 |
# File 'lib/git/path.rb', line 24 def writable? File.writable?(@path) end |