Sha256: 8f34e4bd1cb21ee1f2cb1602a02c2fdffd38a905c99f2b2ebe899ed6adf8a666

Contents?: true

Size: 803 Bytes

Versions: 135

Compression:

Stored size: 803 Bytes

Contents

module Git
  
  # object that holds all the available branches
  class Branches
    include Enumerable
    
    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(&block)
      @branches.values.each(&block)
    end
    
    def [](symbol)
      @branches[symbol.to_s]
    end
    
    def to_s
      out = ''
      @branches.each do |k, b|
        out << (b.current ? '* ' : '  ') << b.to_s << "\n"
      end
      out
    end
    
  end
end

Version data entries

135 entries across 108 versions & 16 rubygems

Version Path
birkirb-git-1.1.1 lib/git/branches.rb
birkirb-git-1.1.2 lib/git/branches.rb
peterwald-git-1.1.2 lib/git/branches.rb
peterwald-git-1.1.3 lib/git/branches.rb
peterwald-git-1.1.4 lib/git/branches.rb
schacon-git-1.1.1 lib/git/branches.rb
schacon-git-1.2.0 lib/git/branches.rb
schacon-git-1.2.1 lib/git/branches.rb
schacon-git-1.2.2 lib/git/branches.rb
technicalpickles-git-1.1.1 lib/git/branches.rb
devise_sociable-0.1.0 vendor/bundle/gems/git-1.2.5/lib/git/branches.rb
ruby-git-lacravate-0.0.2 lib/git/branches.rb
ruby-git-lacravate-0.0.1 lib/git/branches.rb
dirty_history-0.7.3 dirty_history/ruby/1.9.1/gems/git-1.2.5/lib/git/branches.rb
dirty_history-0.7.2 dirty_history/ruby/1.9.1/gems/git-1.2.5/lib/git/branches.rb
dirty_history-0.7.1 dirty_history/ruby/1.9.1/gems/git-1.2.5/lib/git/branches.rb
dirty_history-0.7.0 dirty_history/ruby/1.9.1/gems/git-1.2.5/lib/git/branches.rb
dirty_history-0.6.7 dirty_history/ruby/1.9.1/gems/git-1.2.5/lib/git/branches.rb
dirty_history-0.6.6 dirty_history/ruby/1.9.1/gems/git-1.2.5/lib/git/branches.rb
dirty_history-0.6.5 dirty_history/ruby/1.9.1/gems/git-1.2.5/lib/git/branches.rb