Class: Mastodon::Todo
- Inherits:
-
Struct
- Object
- Struct
- Mastodon::Todo
- Includes:
- Comparable
- Defined in:
- lib/mastodon/todo.rb
Instance Attribute Summary (collapse)
-
- (Object) contexts
Returns the value of attribute contexts.
-
- (Object) priority
Returns the value of attribute priority.
-
- (Object) projects
Returns the value of attribute projects.
-
- (Object) text
Returns the value of attribute text.
Instance Method Summary (collapse)
-
- (Object) <=>(other_todo)
Comparison operator: Sort todos by their priority first, then sort them by the text.
- - (Object) inspect
- - (Object) to_s
Instance Attribute Details
- (Object) contexts
Returns the value of attribute contexts
2 3 4 |
# File 'lib/mastodon/todo.rb', line 2 def contexts @contexts end |
- (Object) priority
Returns the value of attribute priority
2 3 4 |
# File 'lib/mastodon/todo.rb', line 2 def priority @priority end |
- (Object) projects
Returns the value of attribute projects
2 3 4 |
# File 'lib/mastodon/todo.rb', line 2 def projects @projects end |
- (Object) text
Returns the value of attribute text
2 3 4 |
# File 'lib/mastodon/todo.rb', line 2 def text @text end |
Instance Method Details
- (Object) <=>(other_todo)
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 |
- (Object) inspect
13 14 15 |
# File 'lib/mastodon/todo.rb', line 13 def inspect "#<Mastodon::Todo \"#{to_s}\">" end |
- (Object) to_s
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 |