Class: GitReport::CurrentBranch
- Inherits:
-
Object
- Object
- GitReport::CurrentBranch
- Defined in:
- lib/current_branch.rb
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#project ⇒ Object
Returns the value of attribute project.
Instance Method Summary collapse
-
#initialize(project = nil) ⇒ CurrentBranch
constructor
A new instance of CurrentBranch.
-
#name ⇒ Object
returns the name of the currently checked out branch.
Constructor Details
#initialize(project = nil) ⇒ CurrentBranch
Returns a new instance of CurrentBranch.
5 6 7 8 9 |
# File 'lib/current_branch.rb', line 5 def initialize project = nil raise "No git repo found" unless project @project = project @branch = project.branch end |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch.
3 4 5 |
# File 'lib/current_branch.rb', line 3 def branch @branch end |
#project ⇒ Object
Returns the value of attribute project.
3 4 5 |
# File 'lib/current_branch.rb', line 3 def project @project end |
Instance Method Details
#name ⇒ Object
returns the name of the currently checked out branch
12 13 14 |
# File 'lib/current_branch.rb', line 12 def name @project.branches.select{|b| b.current}.first.full rescue alt_name end |