Class: Git::Branches
Overview
object that holds all the available branches
Instance Method Summary collapse
- #[](symbol) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(base) ⇒ Branches
constructor
A new instance of Branches.
- #local ⇒ Object
- #remote ⇒ Object
-
#size ⇒ Object
array like methods.
- #to_s ⇒ Object
Constructor Details
#initialize(base) ⇒ Branches
Returns a new instance of Branches.
7 8 9 10 11 12 13 14 15 |
# File 'lib/git/branches.rb', line 7 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
35 36 37 |
# File 'lib/git/branches.rb', line 35 def [](symbol) @branches[symbol.to_s] end |
#each(&block) ⇒ Object
31 32 33 |
# File 'lib/git/branches.rb', line 31 def each(&block) @branches.values.each(&block) end |
#local ⇒ Object
17 18 19 |
# File 'lib/git/branches.rb', line 17 def local self.select { |b| !b.remote } end |
#remote ⇒ Object
21 22 23 |
# File 'lib/git/branches.rb', line 21 def remote self.select { |b| b.remote } end |
#size ⇒ Object
array like methods
27 28 29 |
# File 'lib/git/branches.rb', line 27 def size @branches.size end |
#to_s ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/git/branches.rb', line 39 def to_s out = '' @branches.each do |k, b| out << (b.current ? '* ' : ' ') << b.to_s << "\n" end out end |