Class: Lita::Handlers::Flip
- Inherits:
-
Handler
- Object
- Handler
- Lita::Handlers::Flip
- Defined in:
- lib/lita/handlers/flip.rb
Constant Summary collapse
- FLIPPER =
'(╯°□°)╯︵ '.freeze
- FLIPPED_CHARACTERS =
{ '!' => '¡', '?' => '¿', '6' => '9', '9' => '6', 'a' => 'ɐ', 'b' => 'q', 'c' => 'ɔ', 'd' => 'p', 'e' => 'ǝ', 'f' => 'ɟ', 'g' => 'b', 'h' => 'ɥ', 'i' => 'ı', 'j' => 'ɾ', 'k' => 'ʞ', 'l' => 'l', 'm' => 'ɯ', 'n' => 'u', 'o' => 'o', 'p' => 'd', 'q' => 'b', 'r' => 'ɹ', 's' => 's', 't' => 'ʇ', 'u' => 'n', 'v' => 'ʌ', 'w' => 'ʍ', 'x' => 'x', 'y' => 'ʎ', 'z' => 'z', '<' => '>', '>' => '<', '(' => ')', ')' => '(', '[' => ']', ']' => '[', '/' => '\\', '\\' => '/', ',' => '\'', '\'' => ',', }
- FLIPPED_WORDS =
{ 'table' => '┻━┻', ':poop:' => ':icecream:', ':icecream:' => ':poop:' }
Instance Method Summary collapse
Instance Method Details
#flip(response) ⇒ Object
62 63 64 65 66 |
# File 'lib/lita/handlers/flip.rb', line 62 def flip(response) sentence = response.matches.first.first.downcase response.reply "#{ FLIPPER }#{flip_sentence(sentence) }" end |
#flip_sentence(sentence) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/lita/handlers/flip.rb', line 68 def flip_sentence(sentence) sentence. split(/\s+/). map { |word| flip_word(word) }. reverse. join(' ') end |
#flip_word(word) ⇒ Object
76 77 78 79 80 |
# File 'lib/lita/handlers/flip.rb', line 76 def flip_word(word) FLIPPED_WORDS.fetch(word) do |w| w.chars.map { |char| FLIPPED_CHARACTERS[char] }.join.reverse end end |