class String

Public Instance Methods

char_length() click to toggle source
# File lib/tw/client/helper.rb, line 4
def char_length
  self.split(//u).map{|i| i.bytes.length > 1 ? 2 : 1}.reduce(:+)
end
char_length_with_t_co() click to toggle source
# File lib/tw/client/helper.rb, line 8
def char_length_with_t_co
  Tw::Conf.update_twitter_config
  len = self.char_length
  self.scan(Regexp.new "https?://[^\s]+").each do |url|
    len += (url =~ /^https/ ? Tw::Conf['twitter_config']['short_url_length_https'] : Tw::Conf['twitter_config']['short_url_length']) - url.char_length
  end
  len
end
colorize(pattern) click to toggle source
# File lib/tw/app/helper.rb, line 3
def colorize(pattern)
  self.split(/(#{pattern})/).map{|term|
    if term =~ /#{pattern}/
      term = Rainbow(term).color(Tw::App::Render.color_code term).bright.underline
    end
    term
  }.join('')
end