summaryrefslogtreecommitdiffstats
path: root/lib/git/path.rb
blob: 87f5c84e910b0909d716ac9ddcb09b2df764aa13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Git
  class Path
    
    attr_accessor :path
    
    def initialize(path, check_path = true)
      if !check_path || File.exists?(path)
        @path = File.expand_path(path)
      else
        raise ArgumentError, "path does not exist", File.expand_path(path)
      end
    end
    
    def readable?
      File.readable?(@path)
    end

    def writable?
      File.writable?(@path)
    end
    
    def to_s
      @path
    end
    
  end
end