Class: TomatoHarvest::Task
- Inherits:
-
Object
- Object
- TomatoHarvest::Task
- Defined in:
- lib/tomatoharvest/task.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pomodoros ⇒ Object
Returns the value of attribute pomodoros.
Instance Method Summary collapse
-
#initialize(name) ⇒ Task
constructor
A new instance of Task.
- #log_pomodoro(seconds) ⇒ Object
- #logged_minutes ⇒ Object
Constructor Details
#initialize(name) ⇒ Task
Returns a new instance of Task.
7 8 9 10 |
# File 'lib/tomatoharvest/task.rb', line 7 def initialize(name) @name = name @pomodoros = [] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/tomatoharvest/task.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/tomatoharvest/task.rb', line 4 def name @name end |
#pomodoros ⇒ Object
Returns the value of attribute pomodoros.
5 6 7 |
# File 'lib/tomatoharvest/task.rb', line 5 def pomodoros @pomodoros end |
Instance Method Details
#log_pomodoro(seconds) ⇒ Object
12 13 14 15 |
# File 'lib/tomatoharvest/task.rb', line 12 def log_pomodoro(seconds) finished_at = DateTime.now self.pomodoros << Pomodoro.new(seconds, finished_at) end |
#logged_minutes ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/tomatoharvest/task.rb', line 17 def logged_minutes sum = pomodoros.inject(0) do |sum, pomodoro| sum + pomodoro.seconds end sum / 60.0 end |