Class: Project
- Inherits:
-
Object
- Object
- Project
- Defined in:
- lib/trakr/project.rb
Instance Attribute Summary collapse
-
#expected ⇒ Object
Returns the value of attribute expected.
-
#name ⇒ Object
Returns the value of attribute name.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#state ⇒ Object
Returns the value of attribute state.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, expected = nil) ⇒ Project
constructor
A new instance of Project.
- #start_timer ⇒ Object
- #stop_timer ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(name, expected = nil) ⇒ Project
Returns a new instance of Project.
5 6 7 8 9 10 |
# File 'lib/trakr/project.rb', line 5 def initialize(name, expected=nil) @name = name @expected = expected @state = false @time = 0 end |
Instance Attribute Details
#expected ⇒ Object
Returns the value of attribute expected.
2 3 4 |
# File 'lib/trakr/project.rb', line 2 def expected @expected end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/trakr/project.rb', line 2 def name @name end |
#start_time ⇒ Object
Returns the value of attribute start_time.
2 3 4 |
# File 'lib/trakr/project.rb', line 2 def start_time @start_time end |
#state ⇒ Object
Returns the value of attribute state.
2 3 4 |
# File 'lib/trakr/project.rb', line 2 def state @state end |
#time ⇒ Object
Returns the value of attribute time.
2 3 4 |
# File 'lib/trakr/project.rb', line 2 def time @time end |
Class Method Details
.headings ⇒ Object
31 32 33 |
# File 'lib/trakr/project.rb', line 31 def self.headings ['Running', 'Name', 'Time', 'Estimate'] end |
Instance Method Details
#start_timer ⇒ Object
12 13 14 15 |
# File 'lib/trakr/project.rb', line 12 def start_timer @state = true @start_time = Time.now end |
#stop_timer ⇒ Object
17 18 19 20 21 |
# File 'lib/trakr/project.rb', line 17 def stop_timer @state = false @time += Time.now - start_time @start_time = nil end |
#to_a ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/trakr/project.rb', line 23 def to_a if @state [@state.to_s.foreground(:green), @name, (Time.now - @start_time).duration, @expected] else [@state.to_s.foreground(:red), @name, @time.duration, @expected] end end |