Class: GitReport::CurrentBranch

Inherits:
Object
  • Object
show all
Defined in:
lib/current_branch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#branchObject

Returns the value of attribute branch.



3
4
5
# File 'lib/current_branch.rb', line 3

def branch
  @branch
end

#projectObject

Returns the value of attribute project.



3
4
5
# File 'lib/current_branch.rb', line 3

def project
  @project
end

Instance Method Details

#nameObject

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