class MicroManager::CLI::ListTasks

Public Instance Methods

run(schedule:) click to toggle source
# File lib/cli/list_tasks.rb, line 6
def run(schedule:)
  tasks = schedule.outstanding_tasks + schedule.tasks_completed(on: Date.today)
  rows = tasks.map { |task| task_row(task) }
  table = TTY::Table.new(header: ["", "Description", "Due"], rows: rows)
  renderer = TTY::Table::Renderer::Unicode.new(table, padding: [0, 1])

  Result.new { renderer.render }
end

Private Instance Methods

task_row(task) click to toggle source
# File lib/cli/list_tasks.rb, line 17
def task_row(task)
  [
    task.completed? ? "[X]" : "[ ]",
    task.description,
    task.due.to_s
  ]
end