Skip to content

Instantly share code, notes, and snippets.

@ys
Created December 13, 2013 15:12
Show Gist options
  • Save ys/7945680 to your computer and use it in GitHub Desktop.
Save ys/7945680 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
def padded_tweet(message)
if message.size >= 140
message[0..139]
elsif %w{. ! ? …}.include? message[-1]
message.ljust(140, message[-1])
else
message.ljust(140, '!')
end
end
puts padded_tweet(ARGV.first)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment