blob: 72dff0ad79f5663dc3ccb8df16adce6d6bf26b36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
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], b[1])
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
|