Class: PomodoroTimer::Pomodoro

Inherits:
Object
  • Object
show all
Defined in:
lib/pomodoro_timer/pomodoro.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(will_work = false) ⇒ Pomodoro

Returns a new instance of Pomodoro.



5
6
7
8
# File 'lib/pomodoro_timer/pomodoro.rb', line 5

def initialize(will_work=false)
  @running = RunningThread.new(will_work)
  return nil
end

Instance Attribute Details

#runningObject (readonly)

Returns the value of attribute running.



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

def running
  @running
end

Instance Method Details

#cancelObject



21
22
23
# File 'lib/pomodoro_timer/pomodoro.rb', line 21

def cancel
  @running.kill
end

#finished?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/pomodoro_timer/pomodoro.rb', line 25

def finished?
  return @running.cycle.stopped?
end

#show_statusObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/pomodoro_timer/pomodoro.rb', line 10

def show_status
  cycle = @running.cycle
  if cycle.stopped?
    puts "No pomodoro running."
  elsif cycle.break?
    puts "It's break time! (#{format_seconds(cycle.missing_progress)})"
  else
    puts "It's work time! (#{format_seconds(cycle.missing_progress)})"
  end
end