Class: Paradeiser::PomodoriController
- Inherits:
-
Controller
show all
- Defined in:
- lib/paradeiser/controllers/pomodori_controller.rb
Instance Attribute Summary
Attributes inherited from Controller
#exitstatus, #has_output
Instance Method Summary
collapse
Methods inherited from Controller
#call, #get_binding, #initialize, #model, #render
Instance Method Details
#annotate ⇒ Object
49
50
51
52
53
54
|
# File 'lib/paradeiser/controllers/pomodori_controller.rb', line 49
def annotate
raise MissingAnnotationError unless @args && @args.any?
@pom = Repository.all.select{|p| p.kind_of?(Pomodoro)}.sort{|a,b| a.started_at <=> b.started_at}.last
@pom.annotate(@args.join(' '))
Repository.save(@pom)
end
|
#interrupt ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/paradeiser/controllers/pomodori_controller.rb', line 31
def interrupt
@pom = Repository.active
raise NotActiveError unless @pom
raise SingletonError.new(Pomodoro, @pom, :interrupt) if Repository.active? && !@pom.kind_of?(Pomodoro)
@pom.annotate(@args.join(' ')) if @args.any?
if @options.external
@interrupt_type = 'externally'
@pom.interrupt!(:external)
else
@interrupt_type = 'internally'
@pom.interrupt!
end
Repository.save(@pom)
end
|
#log ⇒ Object
56
57
58
59
60
61
62
63
64
|
# File 'lib/paradeiser/controllers/pomodori_controller.rb', line 56
def log
@pom = Pomodoro.new
@pom.id = Repository.next_id
@pom.annotate(@args.join(' ')) if @args.any?
@pom.status = :finished
@pom.finished_at = Time.now
@pom.started_at = @pom.finished_at - Pomodoro::MINUTES_25 * 60
Repository.save(@pom)
end
|