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.



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

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



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

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

#apply(index = nil) ⇒ Object



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

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

#clearObject



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

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

#each(&block) ⇒ Object



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

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

#save(message) ⇒ Object



17
18
19
20
# File 'lib/git/stashes.rb', line 17

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

#sizeObject



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

def size
  @stashes.size
end