Sha256: d3114e7603b6026cca0fa18d2be2461da1e1a579e10ea6c029b11e033ae396e9

Contents?: true

Size: 751 Bytes

Versions: 4

Compression:

Stored size: 751 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

4 entries across 4 versions & 1 rubygems

Version Path
minad-git-1.1.1 lib/git/branches.rb
minad-git-1.1.2 lib/git/branches.rb
minad-git-1.1.3 lib/git/branches.rb
minad-git-1.1.5 lib/git/branches.rb