Class: Mercurial::Branch
- Inherits:
-
Object
- Object
- Mercurial::Branch
- Defined in:
- lib/mercurial-ruby/branch.rb
Overview
The class represents Mercurial branch. Obtained by running an hg branches command.
The class represents Branch object itself, BranchFactory is responsible for assembling instances of Branch. For the list of all possible branch-related operations check BranchFactory.
For general information on Mercurial branches:
Instance Attribute Summary collapse
-
#hash_id ⇒ Object
readonly
ID of a commit associated with the branch.
-
#name ⇒ Object
readonly
Name of the branch.
-
#repository ⇒ Object
readonly
Instance of Repository.
-
#status ⇒ Object
readonly
State of the branch: closed or active.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #closed? ⇒ Boolean
- #commit ⇒ Object
- #inactive? ⇒ Boolean
-
#initialize(repository, name, options = {}) ⇒ Branch
constructor
A new instance of Branch.
Constructor Details
#initialize(repository, name, options = {}) ⇒ Branch
Returns a new instance of Branch.
28 29 30 31 32 33 |
# File 'lib/mercurial-ruby/branch.rb', line 28 def initialize(repository, name, ={}) @repository = repository @name = name.strip @status = ['closed', 'inactive'].include?([:status]) ? [:status] : 'active' @hash_id = [:commit] end |
Instance Attribute Details
#hash_id ⇒ Object (readonly)
ID of a commit associated with the branch. 40-chars long SHA1 hash.
26 27 28 |
# File 'lib/mercurial-ruby/branch.rb', line 26 def hash_id @hash_id end |
#name ⇒ Object (readonly)
Name of the branch.
20 21 22 |
# File 'lib/mercurial-ruby/branch.rb', line 20 def name @name end |
#repository ⇒ Object (readonly)
Instance of Repository.
17 18 19 |
# File 'lib/mercurial-ruby/branch.rb', line 17 def repository @repository end |
#status ⇒ Object (readonly)
State of the branch: closed or active.
23 24 25 |
# File 'lib/mercurial-ruby/branch.rb', line 23 def status @status end |
Instance Method Details
#active? ⇒ Boolean
39 40 41 |
# File 'lib/mercurial-ruby/branch.rb', line 39 def active? status == 'active' end |
#closed? ⇒ Boolean
47 48 49 |
# File 'lib/mercurial-ruby/branch.rb', line 47 def closed? status == 'closed' end |
#commit ⇒ Object
35 36 37 |
# File 'lib/mercurial-ruby/branch.rb', line 35 def commit repository.commits.by_hash_id(hash_id) end |
#inactive? ⇒ Boolean
43 44 45 |
# File 'lib/mercurial-ruby/branch.rb', line 43 def inactive? status == 'inactive' end |