Class: KhoinguyenEhTodoList::Task
- Inherits:
-
Object
- Object
- KhoinguyenEhTodoList::Task
- Defined in:
- lib/khoinguyen_eh_todo_list/task.rb
Overview
Represents a task in the todo list
Instance Attribute Summary collapse
-
#completed ⇒ Object
Returns the value of attribute completed.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
-
#completed? ⇒ Boolean
Returns the completion status.
-
#initialize(title) ⇒ Task
constructor
A new instance of Task.
- #to_s ⇒ Object
-
#toggle_completion ⇒ Object
Toggles the completion status of the task.
Constructor Details
#initialize(title) ⇒ Task
Returns a new instance of Task.
8 9 10 11 |
# File 'lib/khoinguyen_eh_todo_list/task.rb', line 8 def initialize(title) @title = title @completed = false end |
Instance Attribute Details
#completed ⇒ Object
Returns the value of attribute completed.
6 7 8 |
# File 'lib/khoinguyen_eh_todo_list/task.rb', line 6 def completed @completed end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/khoinguyen_eh_todo_list/task.rb', line 6 def title @title end |
Instance Method Details
#completed? ⇒ Boolean
Returns the completion status
20 21 22 |
# File 'lib/khoinguyen_eh_todo_list/task.rb', line 20 def completed? @completed end |
#to_s ⇒ Object
24 25 26 27 |
# File 'lib/khoinguyen_eh_todo_list/task.rb', line 24 def to_s status = @completed ? "[X]" : "[ ]" "#{status} #{@title}" end |
#toggle_completion ⇒ Object
Toggles the completion status of the task
14 15 16 |
# File 'lib/khoinguyen_eh_todo_list/task.rb', line 14 def toggle_completion @completed = !@completed end |