Class: Paradeiser::Pomodoro

Inherits:
Scheduled show all
Defined in:
lib/paradeiser/models/pomodoro.rb

Constant Summary collapse

MINUTES_25 =
25

Instance Attribute Summary collapse

Attributes inherited from Scheduled

#finished_at, #id, #started_at

Instance Method Summary collapse

Methods inherited from Scheduled

#as_json, #name, #new?, #remaining

Constructor Details

#initializePomodoro

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

#annotationsObject (readonly)

Returns the value of attribute annotations.



3
4
5
# File 'lib/paradeiser/models/pomodoro.rb', line 3

def annotations
  @annotations
end

#canceled_atObject

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_typeObject (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

#interruptsObject (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

#durationObject



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

#lengthObject



59
60
61
# File 'lib/paradeiser/models/pomodoro.rb', line 59

def length
  MINUTES_25 * 60
end