Class: Clacky::RichUI::RichWorkPanel
- Inherits:
-
Object
- Object
- Clacky::RichUI::RichWorkPanel
- Includes:
- Components::BaseComponent
- Defined in:
- lib/clacky/rich_ui/components/sidebar_panels.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize ⇒ RichWorkPanel
constructor
A new instance of RichWorkPanel.
- #render ⇒ Object
- #update_activities(activities) ⇒ Object
- #update_plan(text) ⇒ Object
- #update_stats(tasks, cost) ⇒ Object
Methods included from Components::BaseComponent
#colored, #muted, #status_marker, #theme, #truncate
Constructor Details
#initialize ⇒ RichWorkPanel
Returns a new instance of RichWorkPanel.
13 14 15 16 17 18 |
# File 'lib/clacky/rich_ui/components/sidebar_panels.rb', line 13 def initialize @plan = "" @activities = [] @tasks = 0 @cost = 0.0 end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
11 12 13 |
# File 'lib/clacky/rich_ui/components/sidebar_panels.rb', line 11 def height @height end |
#width ⇒ Object
Returns the value of attribute width.
11 12 13 |
# File 'lib/clacky/rich_ui/components/sidebar_panels.rb', line 11 def width @width end |
Instance Method Details
#render ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/clacky/rich_ui/components/sidebar_panels.rb', line 33 def render lines = [] lines << @plan unless @plan.empty? unless @activities.empty? lines << "" unless lines.empty? @activities.each do |a| marker = status_marker(a[:status] || :pending) lines << "#{marker} #{a[:label]}" end end lines << "" unless lines.empty? lines << muted("#{@tasks} tasks ยท $#{@cost.round(4)}") lines.join("\n") end |
#update_activities(activities) ⇒ Object
24 25 26 |
# File 'lib/clacky/rich_ui/components/sidebar_panels.rb', line 24 def update_activities(activities) @activities = Array(activities).last(8) end |
#update_plan(text) ⇒ Object
20 21 22 |
# File 'lib/clacky/rich_ui/components/sidebar_panels.rb', line 20 def update_plan(text) @plan = text.to_s end |
#update_stats(tasks, cost) ⇒ Object
28 29 30 31 |
# File 'lib/clacky/rich_ui/components/sidebar_panels.rb', line 28 def update_stats(tasks, cost) @tasks = tasks.to_i @cost = cost.to_f end |