Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/tw/app/helper.rb,
lib/tw/client/helper.rb
Instance Method Summary collapse
Instance Method Details
#char_length ⇒ Object
4 5 6 |
# 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 ⇒ Object
8 9 10 11 12 13 14 15 |
# 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) ⇒ Object
3 4 5 6 7 8 9 10 |
# 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 |