Sha256: 2353455969a3d32d29783f67e1d901bc1e7e18387551ababffe197ac4b9ee93b
Contents?: true
Size: 866 Bytes
Versions: 2
Compression:
Stored size: 866 Bytes
Contents
class Mastodon class Todo < Struct.new(:text, :contexts, :projects, :priority) include Comparable def to_s pri = priority ? "(#{priority})" : "" ctx = contexts.empty? ? "" : "@#{contexts.join(' @')}" prj = projects.empty? ? "" : "+#{projects.join(' +')}" "#{pri} #{text} #{ctx} #{prj}".strip end def inspect "#<Mastodon::Todo \"#{to_s}\">" end # Comparison operator: Sort todos by their priority first, then sort # them by the text. 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 end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
mastodon-0.3.1 | lib/mastodon/todo.rb |
mastodon2-0.3.1 | lib/mastodon/todo.rb |