Skip to content

Instantly share code, notes, and snippets.

@manleyhimself
Created September 27, 2013 03:42
Show Gist options
  • Save manleyhimself/6723827 to your computer and use it in GitHub Desktop.
Save manleyhimself/6723827 to your computer and use it in GitHub Desktop.
def short(tweets)
sub_hash = { "too" => "2", "to" => "2", "two" => "2", "For" => "4", " for " => " 4 ", "four" => "4", " be " => " b ", "you" => "u", " at " => " @ ", "and" => "&"}
if tweets.length > 140
sub_hash.each do |k,v|
tweets.gsub!(k,v) if tweets.include?(k)
end
if tweets.length > 140
tweets[0,140]
else
tweets
end
else
tweets
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment