Class: Fuso::App
Instance Attribute Summary collapse
-
#active_category ⇒ Object
readonly
Returns the value of attribute active_category.
-
#active_project ⇒ Object
readonly
Returns the value of attribute active_project.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#current_category ⇒ Object
readonly
Returns the value of attribute current_category.
-
#current_project ⇒ Object
readonly
Returns the value of attribute current_project.
-
#report_date ⇒ Object
Returns the value of attribute report_date.
-
#report_mode ⇒ Object
Returns the value of attribute report_mode.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#settings_focus ⇒ Object
Returns the value of attribute settings_focus.
-
#settings_index ⇒ Object
Returns the value of attribute settings_index.
-
#settings_input_buffer ⇒ Object
Returns the value of attribute settings_input_buffer.
-
#settings_input_mode ⇒ Object
Returns the value of attribute settings_input_mode.
-
#settings_message ⇒ Object
Returns the value of attribute settings_message.
-
#toast ⇒ Object
readonly
Returns the value of attribute toast.
Instance Method Summary collapse
- #active_elapsed_seconds ⇒ Object
- #current_timer_seconds ⇒ Object
- #init ⇒ Object
-
#initialize ⇒ App
constructor
A new instance of App.
-
#tracking? ⇒ Boolean
Public state accessors.
- #update(message) ⇒ Object
- #view ⇒ Object
Constructor Details
#initialize ⇒ App
Returns a new instance of App.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fuso/app.rb', line 30 def initialize @config = Config.load @session = Session.load @current_project = @config.default_project @current_category = @config.default_category # Timer state @tracking = false @active_project = nil @active_category = nil @timer_start = nil @timer_accumulated = 0 # seconds accumulated before pause # Screen state @screen = :main # Settings state @settings_focus = :projects @settings_index = 0 @settings_input_mode = false @settings_input_buffer = "" @settings_message = nil # Report state @report_mode = :weekly @report_date = Date.today # Toast notification @toast = nil @toast_expires_at = nil # Views @main_view = Views::MainView.new @settings_view = Views::SettingsView.new @report_view = Views::ReportView.new # Heartbeat for suspend detection @heartbeat = Heartbeat.new end |
Instance Attribute Details
#active_category ⇒ Object (readonly)
Returns the value of attribute active_category.
24 25 26 |
# File 'lib/fuso/app.rb', line 24 def active_category @active_category end |
#active_project ⇒ Object (readonly)
Returns the value of attribute active_project.
24 25 26 |
# File 'lib/fuso/app.rb', line 24 def active_project @active_project end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
22 23 24 |
# File 'lib/fuso/app.rb', line 22 def config @config end |
#current_category ⇒ Object (readonly)
Returns the value of attribute current_category.
23 24 25 |
# File 'lib/fuso/app.rb', line 23 def current_category @current_category end |
#current_project ⇒ Object (readonly)
Returns the value of attribute current_project.
23 24 25 |
# File 'lib/fuso/app.rb', line 23 def current_project @current_project end |
#report_date ⇒ Object
Returns the value of attribute report_date.
27 28 29 |
# File 'lib/fuso/app.rb', line 27 def report_date @report_date end |
#report_mode ⇒ Object
Returns the value of attribute report_mode.
27 28 29 |
# File 'lib/fuso/app.rb', line 27 def report_mode @report_mode end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
22 23 24 |
# File 'lib/fuso/app.rb', line 22 def session @session end |
#settings_focus ⇒ Object
Returns the value of attribute settings_focus.
25 26 27 |
# File 'lib/fuso/app.rb', line 25 def settings_focus @settings_focus end |
#settings_index ⇒ Object
Returns the value of attribute settings_index.
25 26 27 |
# File 'lib/fuso/app.rb', line 25 def settings_index @settings_index end |
#settings_input_buffer ⇒ Object
Returns the value of attribute settings_input_buffer.
26 27 28 |
# File 'lib/fuso/app.rb', line 26 def settings_input_buffer @settings_input_buffer end |
#settings_input_mode ⇒ Object
Returns the value of attribute settings_input_mode.
25 26 27 |
# File 'lib/fuso/app.rb', line 25 def settings_input_mode @settings_input_mode end |
#settings_message ⇒ Object
Returns the value of attribute settings_message.
26 27 28 |
# File 'lib/fuso/app.rb', line 26 def @settings_message end |
#toast ⇒ Object (readonly)
Returns the value of attribute toast.
28 29 30 |
# File 'lib/fuso/app.rb', line 28 def toast @toast end |
Instance Method Details
#active_elapsed_seconds ⇒ Object
131 132 133 134 135 |
# File 'lib/fuso/app.rb', line 131 def active_elapsed_seconds return 0 unless @tracking && @timer_start @timer_accumulated + (Time.now - @timer_start).to_i end |
#current_timer_seconds ⇒ Object
137 138 139 140 141 |
# File 'lib/fuso/app.rb', line 137 def current_timer_seconds return 0 unless @tracking && @timer_start (Time.now - @timer_start).to_i end |
#init ⇒ Object
71 72 73 |
# File 'lib/fuso/app.rb', line 71 def init [self, schedule_tick] end |
#tracking? ⇒ Boolean
Public state accessors
127 128 129 |
# File 'lib/fuso/app.rb', line 127 def tracking? @tracking end |
#update(message) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/fuso/app.rb', line 75 def update() case when TickMessage # Check for suspend via heartbeat staleness if @tracking if (stale_time = @heartbeat.pulse) save_and_stop(at: stale_time) show_toast("Timer stopped — system was suspended") end end # Clear expired toast if @toast && @toast_expires_at && Time.now > @toast_expires_at @toast = nil @toast_expires_at = nil end # Timer ticks — just re-render [self, schedule_tick] when Bubbletea::WindowSizeMessage @width = .width @height = .height [self, nil] when Bubbletea::KeyMessage handle_key() else [self, nil] end end |
#view ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/fuso/app.rb', line 103 def view content = case @screen when :main @main_view.render(self) when :settings @settings_view.render(self) when :report @report_view.render(self) end # Append toast notification if present if @toast content += "\n\n" + Styles.toast.render(@toast) end if @width && @height Lipgloss.place(@width, @height, :center, :center, content) else content end end |