Class: Git::Stashes

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/git/stashes.rb

Overview

object that holds all the available stashes

Instance Method Summary collapse

Constructor Details

#initialize(base) ⇒ Stashes

Returns a new instance of Stashes.



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

def initialize(base)
  @stashes = []
  
  @base = base
        
  @base.lib.stashes_all.each do |id, message|
    @stashes.unshift(Git::Stash.new(@base, message, true))
  end
end

Instance Method Details

#[](index) ⇒ Object



42
43
44
# File 'lib/git/stashes.rb', line 42

def [](index)
  @stashes[index.to_i]
end

#apply(index = 0) ⇒ Object



25
26
27
# File 'lib/git/stashes.rb', line 25

def apply(index=0)
  @base.lib.stash_apply(index.to_i)
end

#clearObject



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

def clear
  @base.lib.stash_clear
  @stashes = []
end

#each(&block) ⇒ Object



38
39
40
# File 'lib/git/stashes.rb', line 38

def each(&block)
  @stashes.each(&block)
end

#save(message) ⇒ Object



20
21
22
23
# File 'lib/git/stashes.rb', line 20

def save(message)
  s = Git::Stash.new(@base, message)
  @stashes.unshift(s) if s.saved?
end

#sizeObject



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

def size
  @stashes.size
end