Sha256: d26ca63d2fcc3cbb5e7f99eb9ad8aa93ba2ab39b27c6334792354953992377c8

Contents?: true

Size: 705 Bytes

Versions: 4

Compression:

Stored size: 705 Bytes

Contents

module Git
  
  # object that holds all the available branches
  class Branches
    include Enumerable
    
    @base = nil
    @branches = nil
    
    def initialize(base)
      @branches = {}
      
      @base = base
            
      @base.lib.branches_all.each do |b|
        @branches[b[0]] = Git::Branch.new(@base, b[0])
      end
    end

    def local
      self.select { |b| !b.remote }
    end
    
    def remote
      self.select { |b| b.remote }
    end
    
    # array like methods

    def size
      @branches.size
    end    
    
    def each
      @branches.each do |k, b|
        yield b
      end
    end
    
    def [](symbol)
      @branches[symbol.to_s]
    end
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
git-1.0.2 lib/git/branches.rb
git-1.0.3 lib/git/branches.rb
git-1.0.1 lib/git/branches.rb
git-1.0.4 lib/git/branches.rb