class History include Ramaze::Helper::CGI def initialize(size = 13) @size = size @history = [] end def write(nick, text) text.strip! return if text.empty? @history.shift until @history.size < @size @history << Message.new(h(nick), h(text), Time.now) true end def to_html @history.map {|message| '
' << [:time, :nick, :text].map{|key| span_for(message, key)}.join("\n") << '
' }.join("\n") end def span_for(message, key) "#{message[key]}" end include Enumerable def each @history.sort.each do |message| yield message end end end