Class: Task
- Inherits:
-
Object
- Object
- Task
- Defined in:
- lib/task_manager.rb
Overview
Define a Task class to represent each task
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#status ⇒ Object
Returns the value of attribute status.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Instance Method Summary collapse
-
#initialize(description, status = 'todo') ⇒ Task
constructor
A new instance of Task.
- #to_h ⇒ Object
- #to_s ⇒ Object
- #update(description, status) ⇒ Object
Constructor Details
#initialize(description, status = 'todo') ⇒ Task
Returns a new instance of Task.
9 10 11 12 13 14 15 |
# File 'lib/task_manager.rb', line 9 def initialize(description, status = 'todo') @id = nil @description = description @status = status @created_at = Time.now @updated_at = Time.now end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
7 8 9 |
# File 'lib/task_manager.rb', line 7 def created_at @created_at end |
#description ⇒ Object
Returns the value of attribute description.
7 8 9 |
# File 'lib/task_manager.rb', line 7 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/task_manager.rb', line 7 def id @id end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/task_manager.rb', line 7 def status @status end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
7 8 9 |
# File 'lib/task_manager.rb', line 7 def updated_at @updated_at end |
Instance Method Details
#to_h ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/task_manager.rb', line 23 def to_h { id: @id, description: @description, status: @status, created_at: @created_at.to_s, updated_at: @updated_at.to_s } end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/task_manager.rb', line 33 def to_s "ID: #{@id} | Description: #{@description} | Status: #{@status} | Created At: #{@created_at} | Updated At: #{@updated_at}" end |
#update(description, status) ⇒ Object
17 18 19 20 21 |
# File 'lib/task_manager.rb', line 17 def update(description, status) @description = description @status = status @updated_at = Time.now end |