class TodoView

Public Class Methods

new(todo) click to toggle source
# File lib/todo_view.rb, line 4
def initialize(todo)
  @todo = todo
end

Public Instance Methods

render() click to toggle source
# File lib/todo_view.rb, line 8
def render
  output = "#{formated_id} #{@todo.description}"
  output += tags
  mark_if_finished(output)
end

Private Instance Methods

formated_id() click to toggle source
# File lib/todo_view.rb, line 15
def formated_id
  if @todo.status == :started
    @todo.id.foreground(:green)
  elsif @todo.status == :pending
    @todo.id.foreground(:yellow)
  else
    @todo.id
  end
end
mark_if_finished(output) click to toggle source
# File lib/todo_view.rb, line 32
def mark_if_finished(output)
  if @todo.status == :finished
    output.foreground(:black)
  else
    output
  end
end
tags() click to toggle source
# File lib/todo_view.rb, line 25
def tags
  return "" if @todo.tags.empty?
  tags = " (#{@todo.tags.join(', ')})"
  tags = tags.foreground(:green) unless @todo.status == :finished
  tags
end