Class: Todo
- Inherits:
-
Object
- Object
- Todo
- Defined in:
- lib/taf/models/todo.rb
Overview
Represents a single todo item in a tree structure
Constant Summary collapse
- MIN_LENGTH =
3
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#idx ⇒ Object
Returns the value of attribute idx.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#status ⇒ Object
Returns the value of attribute status.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #done? ⇒ Boolean
-
#initialize(status:, text:, idx: nil, children: [], parent: nil) ⇒ Todo
constructor
A new instance of Todo.
- #signature ⇒ Object
- #todo? ⇒ Boolean
Constructor Details
#initialize(status:, text:, idx: nil, children: [], parent: nil) ⇒ Todo
Returns a new instance of Todo.
9 10 11 12 13 14 15 |
# File 'lib/taf/models/todo.rb', line 9 def initialize(status:, text:, idx: nil, children: [], parent: nil) @idx = idx @status = status @text = text @children = children @parent = parent end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
5 6 7 |
# File 'lib/taf/models/todo.rb', line 5 def children @children end |
#idx ⇒ Object
Returns the value of attribute idx.
5 6 7 |
# File 'lib/taf/models/todo.rb', line 5 def idx @idx end |
#parent ⇒ Object
Returns the value of attribute parent.
5 6 7 |
# File 'lib/taf/models/todo.rb', line 5 def parent @parent end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/taf/models/todo.rb', line 5 def status @status end |
#text ⇒ Object
Returns the value of attribute text.
5 6 7 |
# File 'lib/taf/models/todo.rb', line 5 def text @text end |
Instance Method Details
#done? ⇒ Boolean
17 18 19 |
# File 'lib/taf/models/todo.rb', line 17 def done? @status == "done" end |
#signature ⇒ Object
25 26 27 |
# File 'lib/taf/models/todo.rb', line 25 def signature Digest::MD5.hexdigest("#{text}|#{parent&.text}") end |
#todo? ⇒ Boolean
21 22 23 |
# File 'lib/taf/models/todo.rb', line 21 def todo? @status == "todo" end |