Class: RageFlip::Flipper

Inherits:
Object
  • Object
show all
Defined in:
lib/rage_flip/flipper.rb

Constant Summary collapse

FORWARD =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-=!@#$%^&*()_+ "
BACKSIDEDOWN =
" +‾()*⅋^%$#{}=-068𝘓95ߤ↋↊⇂zʎxʍʌnʇsɹbdouɯʅʞɾᴉɥƃⅎǝpɔqɐZ⅄XϺɅՈꓕSꓤꝹԀONꟽ⅂ꓘᒋIH⅁ᖵƎᗡϽꓭ∀"

Class Method Summary collapse

Class Method Details

.flip(word) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rage_flip/flipper.rb', line 6

def self.flip(word)
  # Create the upside down map by reversing the backsidedown string
  upsidedown = BACKSIDEDOWN.reverse

  # Create mapping from forward to upsidedown characters
  upsidedownmap = {}
  FORWARD.each_char.with_index do |char, index|
    upsidedownmap[char] = upsidedown[index] if upsidedown[index]
  end

  # Flip the word: reverse the string and map each character
  flipped = ""
  word.each_char do |char|
    mapped_char = upsidedownmap[char] || char
    flipped = mapped_char + flipped
  end

  flipped
end

.flip_text(text) ⇒ Object



40
41
42
# File 'lib/rage_flip/flipper.rb', line 40

def self.flip_text(text)
  flip(text)
end

.rage_flip(text) ⇒ Object



26
27
28
29
30
31
# File 'lib/rage_flip/flipper.rb', line 26

def self.rage_flip(text)
  rageflip_front = "(ノಠ益ಠ)ノ彡┻"
  rageflip_back = ""

  "#{rageflip_front}#{flip(text)}#{rageflip_back}"
end

.table_flip(text) ⇒ Object



33
34
35
36
37
38
# File 'lib/rage_flip/flipper.rb', line 33

def self.table_flip(text)
  table_flip_front = "(╯°□°)╯︵┻"
  table_flip_back = ""

  "#{table_flip_front}#{flip(text)}#{table_flip_back}"
end