Class: Minder::PomodoroFrame

Inherits:
Frame
  • Object
show all
Defined in:
lib/minder/cli/pomodoro_frame.rb

Instance Attribute Summary

Attributes inherited from Frame

#height, #left, #lines, #min_height, #pomodoro_runner, #task_manager, #top, #width, #window

Instance Method Summary collapse

Methods inherited from Frame

#build_window, #erase, #focus, #focused?, #handle_keypress, #has_cursor?, #hidden?, #hide, #initialize, #listen, #move, #parse_template, #print_line, #refresh, #resize, #set_text, #unfocus, #unhide, #window_refresh

Constructor Details

This class inherits a constructor from Minder::Frame

Instance Method Details

#handle_char_keypress(key) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/minder/cli/pomodoro_frame.rb', line 31

def handle_char_keypress(key)
  event = case key
  when ' ' then :continue
  end

  changed
  notify_observers(event)
end

#handle_non_char_keypress(key) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/minder/cli/pomodoro_frame.rb', line 40

def handle_non_char_keypress(key)
  event = case key
  when 3 then :exit
  end

  changed
  notify_observers(event)
end

#periodObject



27
28
29
# File 'lib/minder/cli/pomodoro_frame.rb', line 27

def period
  pomodoro_runner.current_period
end

#pomodorosObject



53
54
55
56
57
# File 'lib/minder/cli/pomodoro_frame.rb', line 53

def pomodoros
  pomodoro_runner.pomodoros_today.map do |pomodoro|
    "\xF0\x9F\x8D\x85 "
  end.join
end

#set_cursor_positionObject



49
50
51
# File 'lib/minder/cli/pomodoro_frame.rb', line 49

def set_cursor_position
  window.setpos(1, lines[0].strip.length + 2)
end

#templateObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/minder/cli/pomodoro_frame.rb', line 5

def template
  text = <<-TEXT
<%= period.title %>  #{pomodoros}
TEXT

  if period.message
    text += <<-TEXT

<%= period.message %>
TEXT
  end

  if task_manager.started_task
    text += <<-TEXT

Working on: #{task_manager.started_task}
TEXT
  end

  text
end