Class: Git::Branches

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/git/branches.rb

Overview

object that holds all the available branches

Instance Method Summary collapse

Constructor Details

#initialize(base) ⇒ Branches

Returns a new instance of Branches.



10
11
12
13
14
15
16
17
18
# File 'lib/git/branches.rb', line 10

def initialize(base)
  @branches = {}
  
  @base = base
        
  @base.lib.branches_all.each do |b|
    @branches[b[0]] = Git::Branch.new(@base, b[0])
  end
end

Instance Method Details

#[](symbol) ⇒ Object



40
41
42
# File 'lib/git/branches.rb', line 40

def [](symbol)
  @branches[symbol.to_s]
end

#eachObject



34
35
36
37
38
# File 'lib/git/branches.rb', line 34

def each
  @branches.each do |k, b|
    yield b
  end
end

#localObject



20
21
22
# File 'lib/git/branches.rb', line 20

def local
  self.select { |b| !b.remote }
end

#remoteObject



24
25
26
# File 'lib/git/branches.rb', line 24

def remote
  self.select { |b| b.remote }
end

#sizeObject

array like methods



30
31
32
# File 'lib/git/branches.rb', line 30

def size
  @branches.size
end