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



50
51
52
# File 'lib/git/stashes.rb', line 50

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

#allArray

Returns an multi-dimensional Array of elements that have been stash saved. Array is based on position and name. See Example

Examples:

Returns Array of items that have been stashed

.all - [0, "testing-stash-all"]]

Returns:

  • (Array)


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

def all
  @base.lib.stashes_all
end

#apply(index = nil) ⇒ Object



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

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

#clearObject



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

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

#each(&block) ⇒ Object



46
47
48
# File 'lib/git/stashes.rb', line 46

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

#save(message) ⇒ Object



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

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

#sizeObject



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

def size
  @stashes.size
end