Class: Ralph::Storage::Task
- Inherits:
-
Object
- Object
- Ralph::Storage::Task
- Defined in:
- lib/ralph/storage/tasks.rb
Overview
Individual task with status and subtasks
Instance Attribute Summary collapse
-
#original_line ⇒ Object
Returns the value of attribute original_line.
-
#status ⇒ Object
Returns the value of attribute status.
-
#subtasks ⇒ Object
Returns the value of attribute subtasks.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #complete? ⇒ Boolean
- #in_progress? ⇒ Boolean
-
#initialize(text:, status: :todo, subtasks: [], original_line: nil) ⇒ Task
constructor
A new instance of Task.
- #mark_complete! ⇒ Object
- #mark_in_progress! ⇒ Object
- #mark_todo! ⇒ Object
- #status_char ⇒ Object
- #to_s ⇒ Object
- #todo? ⇒ Boolean
- #toggle_status ⇒ Object
Constructor Details
#initialize(text:, status: :todo, subtasks: [], original_line: nil) ⇒ Task
Returns a new instance of Task.
98 99 100 101 102 103 |
# File 'lib/ralph/storage/tasks.rb', line 98 def initialize(text:, status: :todo, subtasks: [], original_line: nil) @text = text @status = status @subtasks = subtasks @original_line = original_line end |
Instance Attribute Details
#original_line ⇒ Object
Returns the value of attribute original_line.
96 97 98 |
# File 'lib/ralph/storage/tasks.rb', line 96 def original_line @original_line end |
#status ⇒ Object
Returns the value of attribute status.
96 97 98 |
# File 'lib/ralph/storage/tasks.rb', line 96 def status @status end |
#subtasks ⇒ Object
Returns the value of attribute subtasks.
96 97 98 |
# File 'lib/ralph/storage/tasks.rb', line 96 def subtasks @subtasks end |
#text ⇒ Object
Returns the value of attribute text.
96 97 98 |
# File 'lib/ralph/storage/tasks.rb', line 96 def text @text end |
Instance Method Details
#complete? ⇒ Boolean
119 |
# File 'lib/ralph/storage/tasks.rb', line 119 def complete? = status == :complete |
#in_progress? ⇒ Boolean
118 |
# File 'lib/ralph/storage/tasks.rb', line 118 def in_progress? = status == :in_progress |
#mark_complete! ⇒ Object
129 |
# File 'lib/ralph/storage/tasks.rb', line 129 def mark_complete! = @status = :complete |
#mark_in_progress! ⇒ Object
130 |
# File 'lib/ralph/storage/tasks.rb', line 130 def mark_in_progress! = @status = :in_progress |
#mark_todo! ⇒ Object
131 |
# File 'lib/ralph/storage/tasks.rb', line 131 def mark_todo! = @status = :todo |
#status_char ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/ralph/storage/tasks.rb', line 105 def status_char case status when :complete then "x" when :in_progress then "/" else " " end end |
#to_s ⇒ Object
113 114 115 |
# File 'lib/ralph/storage/tasks.rb', line 113 def to_s "- [#{status_char}] #{text}" end |
#todo? ⇒ Boolean
117 |
# File 'lib/ralph/storage/tasks.rb', line 117 def todo? = status == :todo |
#toggle_status ⇒ Object
121 122 123 124 125 126 127 |
# File 'lib/ralph/storage/tasks.rb', line 121 def toggle_status case status when :todo then @status = :in_progress when :in_progress then @status = :complete when :complete then @status = :todo end end |