Class: Todo::Task
- Inherits:
-
Object
- Object
- Todo::Task
- 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
#highlight_as_project ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/gem_ext/todo-txt.rb', line 24 def highlight_as_project return to_s unless STDOUT.tty? pastel = Pastel.new [ pastel.bold.cyan(print_projects), pastel.red(print_project_context) ].reject { |item| !item || item.nil? || item.empty? }.join(' ') end |
#text=(label) ⇒ Object
34 35 36 |
# File 'lib/gem_ext/todo-txt.rb', line 34 def text=(label) @text = label end |
#to_s_highlighted ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# 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 [ pastel.red(print_priority), pastel.yellow(created_on.to_s), text, pastel.bold.magenta(print_contexts), pastel.bold.blue(print_projects), pastel.bold.cyan() ].reject { |item| !item || item.nil? || item.empty? }.join(' ') end end |