class Git::Stashes

object that holds all the available stashes

Public Class Methods

new(base) click to toggle source
# File lib/git/stashes.rb, line 8
def initialize(base)
  @stashes = []

  @base = base

  @base.lib.stashes_all.each do |indexed_message|
    _index, message = indexed_message
    @stashes.unshift(Git::Stash.new(@base, message, save: true))
  end
end

Public Instance Methods

[](index) click to toggle source
# File lib/git/stashes.rb, line 52
def [](index)
  @stashes[index.to_i]
end
all() click to toggle source

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

@example Returns Array of items that have been stashed

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

@return [Array]

# File lib/git/stashes.rb, line 26
def all
  @base.lib.stashes_all
end
apply(index = nil) click to toggle source
# File lib/git/stashes.rb, line 35
def apply(index = nil)
  @base.lib.stash_apply(index)
end
clear() click to toggle source
# File lib/git/stashes.rb, line 39
def clear
  @base.lib.stash_clear
  @stashes = []
end
each(&) click to toggle source
# File lib/git/stashes.rb, line 48
def each(&)
  @stashes.each(&)
end
save(message) click to toggle source
# File lib/git/stashes.rb, line 30
def save(message)
  s = Git::Stash.new(@base, message)
  @stashes.unshift(s) if s.saved?
end
size() click to toggle source
# File lib/git/stashes.rb, line 44
def size
  @stashes.size
end