Class: Medo::TextTaskWriter::TaskPresenter
- Inherits:
-
Object
- Object
- Medo::TextTaskWriter::TaskPresenter
- Defined in:
- lib/medo/text_task_writer.rb
Defined Under Namespace
Classes: Components
Instance Method Summary collapse
- #description(length = nil, options = {}) ⇒ Object
- #done ⇒ Object
-
#initialize(task) ⇒ TaskPresenter
constructor
A new instance of TaskPresenter.
- #notes(length = nil, options = {}) ⇒ Object
- #time ⇒ Object
- #to_s(length = nil) ⇒ Object
Constructor Details
#initialize(task) ⇒ TaskPresenter
Returns a new instance of TaskPresenter.
54 55 56 |
# File 'lib/medo/text_task_writer.rb', line 54 def initialize(task) @task = task end |
Instance Method Details
#description(length = nil, options = {}) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/medo/text_task_writer.rb', line 58 def description(length = nil, = {}) if length break_line_to_fit(@task.description, length, ) else @task.description end end |
#done ⇒ Object
86 87 88 |
# File 'lib/medo/text_task_writer.rb', line 86 def done "[#{@task.done? ? '+' : ' '}]" end |
#notes(length = nil, options = {}) ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/medo/text_task_writer.rb', line 75 def notes(length = nil, = {}) return "" if @task.notes.empty? "\n\n" + @task.notes.map do |n| if length break_line_to_fit(n, length, ) else n.rjust(n.size + done.size + 1) end end.join("\n") + "\n\n" end |
#time ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/medo/text_task_writer.rb', line 66 def time format = "%H:%M" if @task.done? "[#{@task.completed_at.strftime(format)}]" else "(#{@task.created_at.strftime(format)})" end end |
#to_s(length = nil) ⇒ Object
90 91 92 93 |
# File 'lib/medo/text_task_writer.rb', line 90 def to_s(length = nil) c = components(length) "#{c.done} #{c.description} #{c.time}#{c.notes}" end |