Sha256: f2c0bd44bc386f29f53f17f53d6f194bf5ab9ddb6472b922e2df702ac2e6d235
Contents?: true
Size: 672 Bytes
Versions: 1
Compression:
Stored size: 672 Bytes
Contents
class History include Ramaze::Helper::CGI def initialize(size = 13) @size = size @history = [] end def write(nick, text) return if text.empty? @history.shift until @history.size < @size @history << Message.new(nick, text, Time.now) true end def to_html @history.map{|message| "<div class='message'>" + [:nick, :time, :text].map{|key| span_for(message, key) }.join("\n") + "</div>" }.join("\n") end def span_for(message, key) "<span class='#{key}'>#{h(message[key])}</span>" end include Enumerable def each @history.sort.each do |message| yield message end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clivecrous-ramaze-0.3.9.5 | examples/chat/model/history.rb |