Sha256: 515933f89444c2b3f5dbf3b633675f393b9ce35814c97808cacb06c1958d34a7
Contents?: true
Size: 669 Bytes
Versions: 2
Compression:
Stored size: 669 Bytes
Contents
module Tw::App class Render def self.color_code(str) 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| 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('') } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tw-0.0.3 | lib/tw/app/render.rb |
tw-0.0.2 | lib/tw/app/render.rb |