Class: PT::Flow::Branch
- Inherits:
-
Object
- Object
- PT::Flow::Branch
- Defined in:
- lib/pt-flow/branch.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) ⇒ Branch
constructor
A new instance of Branch.
- #target ⇒ Object
- #task_id ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ Branch
Returns a new instance of Branch.
16 17 18 |
# File 'lib/pt-flow/branch.rb', line 16 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/pt-flow/branch.rb', line 6 def name @name end |
Class Method Details
.current ⇒ Object
8 9 10 |
# File 'lib/pt-flow/branch.rb', line 8 def self.current new(`git rev-parse --abbrev-ref HEAD`.strip) end |
.from_task(task) ⇒ Object
12 13 14 |
# File 'lib/pt-flow/branch.rb', line 12 def self.from_task(task) new("#{current.target}.#{task.name.parameterize[0..50]}.#{task.id}") end |
Instance Method Details
#target ⇒ Object
20 21 22 |
# File 'lib/pt-flow/branch.rb', line 20 def target name.split('.').first end |
#task_id ⇒ Object
24 25 26 |
# File 'lib/pt-flow/branch.rb', line 24 def task_id name[/\d+$/] || '' end |
#to_s ⇒ Object
28 29 30 |
# File 'lib/pt-flow/branch.rb', line 28 def to_s name end |