commit fc439ec03648de6ea0a5736eee12a787cbda03e7
parent 1f5cf842c54333b78a9d22ce1da1d5ef947128c5
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Sun, 28 Oct 2007 01:22:16 +0000
even better thread snippets
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@635 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/sup/thread.rb b/lib/sup/thread.rb
@@ -85,7 +85,10 @@ class Thread
def first; each { |m, *o| return m if m }; nil; end
def dirty?; any? { |m, *o| m && m.dirty? }; end
def date; map { |m, *o| m.date if m }.compact.max; end
- def snippet; sort_by { |m, d, p| -d }.argfind { |m, d, p| m && !m.snippet.empty? && m.snippet } || "" end
+ def snippet
+ last_m, last_stuff = select { |m, *o| m && m.snippet && !m.snippet.empty? }.sort_by { |m, *o| m.date }.last
+ last_m ? last_m.snippet : ""
+ end
def authors; map { |m, *o| m.from if m }.compact.uniq; end
def apply_label t; each { |m, *o| m && m.add_label(t) }; end