Last active
December 20, 2015 11:39
-
-
Save banderson/6125480 to your computer and use it in GitHub Desktop.
Ruby Script to flip text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!/usr/bin/env ruby | |
# encoding: UTF-8 | |
# adapted from http://www.leancrew.com/all-this/2009/05/im-feelin-upside-down/ | |
class Flipper | |
CHARS = " abcdefghijklmnopqrstuvwxyz,.?!'()[]{}".split('') | |
FLIPPED_CHARS = " ɐqɔpǝɟƃɥıɾʞlɯuodbɹsʇnʌʍxʎz'˙¿¡,)(][}{".split('') | |
DICTIONARY = Hash[CHARS.zip FLIPPED_CHARS] | |
def self.doit(phrase) | |
phrase.downcase.reverse.split('').map do |char| | |
DICTIONARY[char] | |
end.join '' | |
end | |
end | |
phrase = ARGV.first | |
raise 'You must provide a phrase to reverse' if phrase.nil? | |
puts Flipper.doit phrase |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flip "{query}" | pbcopy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment