# File lib/sup/thread.rb, line 100 def apply_label t; each { |m, *o| m && m.add_label(t) }; end
# File lib/sup/thread.rb, line 89 def date; map { |m, *o| m.date if m }.compact.max; end
# File lib/sup/thread.rb, line 117 def direct_participants map { |m, *o| [m.from] + m.to if m }.flatten.compact.uniq end
# File lib/sup/thread.rb, line 88 def dirty?; any? { |m, *o| m && m.dirty? }; end
# File lib/sup/thread.rb, line 48 def drop c; @containers.delete(c) or raise "bad drop"; end
unused
# File lib/sup/thread.rb, line 51 def dump f=$stdout f.puts "=== start thread with #{@containers.length} trees ===" @containers.each { |c| c.dump_recursive f; f.puts } f.puts "=== end thread ===" end
yields each message, its depth, and its parent. the message yield parameter can be a Message object, or :fake_root, or nil (no message found but the presence of one deduced from other messages).
# File lib/sup/thread.rb, line 61 def each fake_root=false adj = 0 root = @containers.find_all { |c| c.message && !Message.subj_is_reply?(c.message.subj) }.argmin { |c| c.date } if root adj = 1 root.first_useful_descendant.each_with_stuff do |c, d, par| yield c.message, d, (par ? par.message : nil) end elsif @containers.length > 1 && fake_root adj = 1 yield :fake_root, 0, nil end @containers.each do |cont| next if cont == root fud = cont.first_useful_descendant fud.each_with_stuff do |c, d, par| ## special case here: if we're an empty root that's already ## been joined by a fake root, don't emit yield c.message, d + adj, (par ? par.message : nil) unless fake_root && c.message.nil? && root.nil? && c == fud end end end
# File lib/sup/thread.rb, line 115 def each_dirty_message; each { |m, *o| m && m.dirty? && yield(m) }; end
# File lib/sup/thread.rb, line 47 def empty!; @containers.clear; end
# File lib/sup/thread.rb, line 46 def empty?; @containers.empty?; end
# File lib/sup/thread.rb, line 87 def first; each { |m, *o| return m if m }; nil; end
# File lib/sup/thread.rb, line 114 def has_label? t; any? { |m, *o| m && m.has_label?(t) }; end
# File lib/sup/thread.rb, line 127 def labels; inject(Set.new) { |s, (m, *o)| m ? s | m.labels : s } end
# File lib/sup/thread.rb, line 128 def labels= l raise ArgumentError, "not a set" unless l.is_a?(Set) each { |m, *o| m && m.labels = l.dup } end
# File lib/sup/thread.rb, line 133 def latest_message inject(nil) do |a, b| b = b.first if a.nil? b elsif b.nil? a else b.date > a.date ? b : a end end end
# File lib/sup/thread.rb, line 121 def participants map { |m, *o| [m.from] + m.to + m.cc + m.bcc if m }.flatten.compact.uniq end
# File lib/sup/thread.rb, line 101 def remove_label t; each { |m, *o| m && m.remove_label(t) }; end
# File lib/sup/thread.rb, line 113 def set_labels l; each { |m, *o| m && m.labels = l }; end
# File lib/sup/thread.rb, line 125 def size; map { |m, *o| m ? 1 : 0 }.sum; end
# File lib/sup/thread.rb, line 90 def snippet with_snippets = select { |m, *o| m && m.snippet && !m.snippet.empty? } first_unread, * = with_snippets.select { |m, *o| m.has_label?(:unread) }.sort_by { |m, *o| m.date }.first return first_unread.snippet if first_unread last_read, * = with_snippets.sort_by { |m, *o| m.date }.last return last_read.snippet if last_read "" end
# File lib/sup/thread.rb, line 126 def subj; argfind { |m, *o| m && m.subj }; end
Generated with the Darkfish Rdoc Generator 2.