Sha256: 8e8271e530eaab59ce3ae1016609943f2fce4f441b59f29694459e25ab100f12
Contents?: true
Size: 424 Bytes
Versions: 1
Compression:
Stored size: 424 Bytes
Contents
class TweetSpeak SHORTHAND = { 'are' => 'r', 'you' => 'u', 'your' => 'ur', "you're" => 'ur', 'to' => '2', 'because' => 'b/c', 'before' => 'b4', 'for' => '4', 'with' => 'w/', 'without' => 'w/o' } def self.twittify(tweet) regex = /(\W*)(#{SHORTHAND.keys.join('|')})(\W+|$)/i tweet.gsub(regex) do |match| $1 + SHORTHAND[$2] + $3 end.gsub(/\s+/, ' ') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tweetspeak-0.1.0 | lib/tweet_speak.rb |