Sha256: eab16f5af8108587d91116ff19ad6f8845fdf588bf1419539c3f52bb76f2778c

Contents?: true

Size: 819 Bytes

Versions: 4

Compression:

Stored size: 819 Bytes

Contents

module Git
  
  # object that holds all the available stashes
  class Stashes
    include Enumerable
    
    @base = nil
    @stashes = nil
    
    def initialize(base)
      @stashes = []
      
      @base = base
            
      @base.lib.stashes_all.each do |id, message|
        @stashes.unshift(Git::Stash.new(@base, message, true))
      end
    end
    
    def save(message)
      s = Git::Stash.new(@base, message)
      @stashes.unshift(s) if s.saved?
    end
    
    def apply(index=0)
      @base.lib.stash_apply(index.to_i)
    end
    
    def clear
      @base.lib.stash_clear
      @stashes = []
    end

    def size
      @stashes.size
    end
    
    def each
      @stashes.each do |s|
        yield s
      end
    end
    
    def [](index)
      @stashes[index.to_i]
    end
    
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
iownbey-git-1.0.7.1 lib/git/stashes.rb
schacon-git-1.0.6 lib/git/stashes.rb
schacon-git-1.0.7 lib/git/stashes.rb
git-1.0.5 lib/git/stashes.rb