Class: Todo::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_ext/todo-txt.rb

Overview

Monkeypatch todo-txt-gem to create ANSI decorated terminal output.

Instance Method Summary collapse

Instance Method Details

#to_s_highlighted ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/gem_ext/todo-txt.rb', line 3

def to_s_highlighted
  # If stdout is not a tty, then return the raw string as the output is
  # probably being piped to a file and the color codes will make a mess.
  return to_s unless STDOUT.tty?

  pastel = Pastel.new
  if done?
    # Completed tasks are rendered with a strikethrough
    pastel.strikethrough(to_s)
  else
    # Open tasks delegate to the custom formatting function
    print_open_task(pastel)
  end
end