Class: EnigmaEncrypto::Rotator
- Inherits:
-
Object
- Object
- EnigmaEncrypto::Rotator
- Defined in:
- lib/enigma_encrypto/rotator.rb
Instance Method Summary collapse
- #character_map_creation ⇒ Object
- #reverse_text(text, reversion) ⇒ Object
- #rotate_text(text, rotation) ⇒ Object
- #rotator(rotation) ⇒ Object
Instance Method Details
#character_map_creation ⇒ Object
4 5 6 7 8 9 |
# File 'lib/enigma_encrypto/rotator.rb', line 4 def character_map_creation @character_map = [] @character_map.concat(("a".."z").to_a) @character_map.concat(("0".."9").to_a) @character_map.concat([" ", ".", ","]) end |
#reverse_text(text, reversion) ⇒ Object
19 20 21 22 |
# File 'lib/enigma_encrypto/rotator.rb', line 19 def reverse_text(text, reversion) reversion = 0 - reversion rotate_text(text, reversion) end |
#rotate_text(text, rotation) ⇒ Object
15 16 17 18 |
# File 'lib/enigma_encrypto/rotator.rb', line 15 def rotate_text(text, rotation) rotation_for_text = rotator(rotation) rotation_for_text[text] end |
#rotator(rotation) ⇒ Object
10 11 12 13 14 |
# File 'lib/enigma_encrypto/rotator.rb', line 10 def rotator(rotation) character_map_creation rotated_character_map = @character_map.rotate(rotation) Hash[@character_map.zip(rotated_character_map)] end |