added branches, more log stuff, better tests, changed the log api a bit
[rubygit.git] / lib / git / branches.rb
blob81abe222e509e5280e3c011871b909009da10cc6
1 module Git
2   
3   # object that holds all the available branches
4   class Branches
5     include Enumerable
6     
7     @base = nil
8     @branches = nil
9     
10     def initialize(base)
11       @branches = {}
12       
13       @base = base
14       @base.lib.branches_all.each do |b|
15         @branches[b.full] = b
16       end
17     end
19     def local
20       self.select { |b| !b.remote }
21     end
22     
23     def remote
24       self.select { |b| b.remote }
25     end
26     
27     # array like methods
29     def size
30       @branches.size
31     end    
32     
33     def each
34       @branches.each do |k, b|
35         yield b
36       end
37     end
38     
39     def [](symbol)
40       @branches[symbol.to_s]
41     end
42     
43   end
44 end