Class: Clacky::RichTodoSidebar

Inherits:
Object
  • Object
show all
Defined in:
lib/clacky/rich_ui_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tasks: []) ⇒ RichTodoSidebar

Returns a new instance of RichTodoSidebar.



327
328
329
330
331
# File 'lib/clacky/rich_ui_controller.rb', line 327

def initialize(tasks: [])
  @tasks = tasks
  @width = 0
  @height = 0
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



324
325
326
# File 'lib/clacky/rich_ui_controller.rb', line 324

def height
  @height
end

#tasksObject (readonly)

Returns the value of attribute tasks.



325
326
327
# File 'lib/clacky/rich_ui_controller.rb', line 325

def tasks
  @tasks
end

#widthObject

Returns the value of attribute width.



324
325
326
# File 'lib/clacky/rich_ui_controller.rb', line 324

def width
  @width
end

Instance Method Details

#add_task(label, status: :pending) ⇒ Object



342
343
344
345
# File 'lib/clacky/rich_ui_controller.rb', line 342

def add_task(label, status: :pending)
  @tasks << { label: label, status: status }
  self
end

#renderObject



347
348
349
350
351
352
# File 'lib/clacky/rich_ui_controller.rb', line 347

def render
  panel = RubyRich::Panel.new(render_tasks, title: "Todos", border_style: :blue, title_align: :left)
  panel.width = @width
  panel.height = @height
  panel.render
end

#set_tasks(tasks) ⇒ Object



337
338
339
340
# File 'lib/clacky/rich_ui_controller.rb', line 337

def set_tasks(tasks)
  @tasks = Array(tasks)
  self
end

#update_plan(_text) ⇒ Object



333
334
335
# File 'lib/clacky/rich_ui_controller.rb', line 333

def update_plan(_text)
  self
end