Class: Mastodon::Todo
- Inherits:
-
Struct
- Object
- Struct
- Mastodon::Todo
- Includes:
- Comparable
- Defined in:
- lib/mastodon/todo.rb
Instance Attribute Summary collapse
-
#contexts ⇒ Object
Returns the value of attribute contexts.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#projects ⇒ Object
Returns the value of attribute projects.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#<=>(other_todo) ⇒ Object
Comparison operator: Sort todos by their priority first, then sort them by the text.
- #inspect ⇒ Object
- #to_s ⇒ Object
Instance Attribute Details
#contexts ⇒ Object
Returns the value of attribute contexts
2 3 4 |
# File 'lib/mastodon/todo.rb', line 2 def contexts @contexts end |
#priority ⇒ Object
Returns the value of attribute priority
2 3 4 |
# File 'lib/mastodon/todo.rb', line 2 def priority @priority end |
#projects ⇒ Object
Returns the value of attribute projects
2 3 4 |
# File 'lib/mastodon/todo.rb', line 2 def projects @projects end |
#text ⇒ Object
Returns the value of attribute text
2 3 4 |
# File 'lib/mastodon/todo.rb', line 2 def text @text end |
Instance Method Details
#<=>(other_todo) ⇒ Object
Comparison operator: Sort todos by their priority first, then sort them by the text.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mastodon/todo.rb', line 19 def <=>(other_todo) return -1 if (priority.nil? and !other_todo.priority.nil?) pri = (priority <=> other_todo.priority) if pri == 0 return text <=> other_todo.text else return pri end end |
#inspect ⇒ Object
13 14 15 |
# File 'lib/mastodon/todo.rb', line 13 def inspect "#<Mastodon::Todo \"#{to_s}\">" end |
#to_s ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/mastodon/todo.rb', line 5 def to_s pri = priority ? "(#{priority})" : "" ctx = contexts.empty? ? "" : "@#{contexts.join(' @')}" prj = projects.empty? ? "" : "+#{projects.join(' +')}" "#{pri} #{text} #{ctx} #{prj}".strip end |