Sha256: 24dff39cd436c0a44c3943bcf0072b9c2800784a67a2d8b020dd5a09e3c63aff
Contents?: true
Size: 663 Bytes
Versions: 3
Compression:
Stored size: 663 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(arr) arr = [arr] unless arr.kind_of? Array arr.flatten.sort{|a,b| a[:id] <=> b[:id] }.uniq.each{|m| 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} : #{CGI.unescapeHTML m[:text]}" puts line.colorize(/@[a-zA-Z0-9_]+/) } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tw-0.2.4 | lib/tw/app/render.rb |
tw-0.2.3 | lib/tw/app/render.rb |
tw-0.2.2 | lib/tw/app/render.rb |