Class: Paradeiser::Pomodoro
- Defined in:
- lib/paradeiser/models/pomodoro.rb
Constant Summary collapse
- MINUTES_25 =
25
Instance Attribute Summary collapse
-
#annotations ⇒ Object
readonly
Returns the value of attribute annotations.
-
#canceled_at ⇒ Object
Returns the value of attribute canceled_at.
-
#interrupt_type ⇒ Object
readonly
Returns the value of attribute interrupt_type.
-
#interrupts ⇒ Object
readonly
Returns the value of attribute interrupts.
Attributes inherited from Scheduled
#finished_at, #id, #started_at
Instance Method Summary collapse
- #annotate(text) ⇒ Object
- #duration ⇒ Object
-
#initialize ⇒ Pomodoro
constructor
A new instance of Pomodoro.
- #interrupt!(type = nil) ⇒ Object
- #length ⇒ Object
Methods inherited from Scheduled
#as_json, #name, #new?, #remaining
Constructor Details
#initialize ⇒ Pomodoro
Returns a new instance of Pomodoro.
52 53 54 55 56 57 |
# File 'lib/paradeiser/models/pomodoro.rb', line 52 def initialize super # required for state_machine @interrupts = [] @annotations = [] start! end |
Instance Attribute Details
#annotations ⇒ Object (readonly)
Returns the value of attribute annotations.
3 4 5 |
# File 'lib/paradeiser/models/pomodoro.rb', line 3 def annotations @annotations end |
#canceled_at ⇒ Object
Returns the value of attribute canceled_at.
4 5 6 |
# File 'lib/paradeiser/models/pomodoro.rb', line 4 def canceled_at @canceled_at end |
#interrupt_type ⇒ Object (readonly)
Returns the value of attribute interrupt_type.
3 4 5 |
# File 'lib/paradeiser/models/pomodoro.rb', line 3 def interrupt_type @interrupt_type end |
#interrupts ⇒ Object (readonly)
Returns the value of attribute interrupts.
3 4 5 |
# File 'lib/paradeiser/models/pomodoro.rb', line 3 def interrupts @interrupts end |
Instance Method Details
#annotate(text) ⇒ Object
74 75 76 |
# File 'lib/paradeiser/models/pomodoro.rb', line 74 def annotate(text) @annotations << text end |
#duration ⇒ Object
68 69 70 71 72 |
# File 'lib/paradeiser/models/pomodoro.rb', line 68 def duration start = started_at || Time.now finish = finished_at || canceled_at || Time.now (finish - start).to_i end |
#interrupt!(type = nil) ⇒ Object
63 64 65 66 |
# File 'lib/paradeiser/models/pomodoro.rb', line 63 def interrupt!(type = nil) @interrupt_type = type super end |
#length ⇒ Object
59 60 61 |
# File 'lib/paradeiser/models/pomodoro.rb', line 59 def length MINUTES_25 * 60 end |