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.


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

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


7
8
9
# File 'lib/git/worktree.rb', line 7

def dir
  @dir
end

#full

Returns the value of attribute full


7
8
9
# File 'lib/git/worktree.rb', line 7

def full
  @full
end

#gcommit

Returns the value of attribute gcommit


7
8
9
# File 'lib/git/worktree.rb', line 7

def gcommit
  @gcommit
end

Instance Method Details

#add


22
23
24
# File 'lib/git/worktree.rb', line 22

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

#remove


26
27
28
# File 'lib/git/worktree.rb', line 26

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

#to_a


30
31
32
# File 'lib/git/worktree.rb', line 30

def to_a
  [@full]
end

#to_s


34
35
36
# File 'lib/git/worktree.rb', line 34

def to_s
  @full
end