lib/tw/app/render.rb in tw-0.0.3 vs lib/tw/app/render.rb in tw-0.1.0

- old
+ new

@@ -5,20 +5,16 @@ colors = Sickill::Rainbow::TERM_COLORS.keys - [:default, :black, :white] n = str.each_byte.map{|c| c.to_i}.inject{|a,b|a+b} return colors[n%colors.size] end - def self.display(hash) - hash.flatten.sort{|a,b| + def self.display(arr) + arr.flatten.sort{|a,b| a[:id] <=> b[:id] }.uniq.each{|m| - line = "#{m[:time].strftime '[%m/%d %a] (%H:%M:%S)'} @#{m[:user]} : #{m[:text]}" - puts line.split(/(@[a-zA-Z0-9_]+)/).map{|term| - if term =~ /@[a-zA-Z0-9_]+/ - term = term.color(color_code term).bright.underline - end - term - }.join('') + user = m[:user].kind_of?(Hash) ? "@#{m[:user][:from]} > @#{m[:user][:to]}" : "@#{m[:user]}" + line = "#{m[:time].strftime '[%m/%d %a] (%H:%M:%S)'} #{user} : #{m[:text]}" + puts line.colorize(/@[a-zA-Z0-9_]+/) } end end end