Class: Git::Worktree

Inherits:
Path
  • Object
show all
Defined in:
lib/git/worktree.rb

Instance Attribute Summary collapse

Attributes inherited from Path

#path

Instance Method Summary collapse

Methods inherited from Path

#readable?, #writable?

Constructor Details

#initialize(base, dir, gcommit = nil) ⇒ Worktree

Returns a new instance of Worktree.



11
12
13
14
15
16
17
# File 'lib/git/worktree.rb', line 11

def initialize(base, dir, gcommit = nil)
  @full = dir
  @full += ' ' + gcommit if !gcommit.nil?
  @base = base
  @dir = dir
  @gcommit = gcommit
end

Instance Attribute Details

#dir

Returns the value of attribute dir.



9
10
11
# File 'lib/git/worktree.rb', line 9

def dir
  @dir
end

#full

Returns the value of attribute full.



9
10
11
# File 'lib/git/worktree.rb', line 9

def full
  @full
end

#gcommit

Returns the value of attribute gcommit.



9
10
11
# File 'lib/git/worktree.rb', line 9

def gcommit
  @gcommit
end

Instance Method Details

#add



24
25
26
# File 'lib/git/worktree.rb', line 24

def add
  @base.lib.worktree_add(@dir, @gcommit)
end

#remove



28
29
30
# File 'lib/git/worktree.rb', line 28

def remove
  @base.lib.worktree_remove(@dir)
end

#to_a



32
33
34
# File 'lib/git/worktree.rb', line 32

def to_a
  [@full]
end

#to_s



36
37
38
# File 'lib/git/worktree.rb', line 36

def to_s
  @full
end