Module: GravityFallsMessage
- Defined in:
- lib/gravity_falls_message.rb,
lib/gravity_falls_message/cipher.rb,
lib/gravity_falls_message/version.rb
Defined Under Namespace
Classes: Cipher
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
Class Method Details
.decode(message, cipher, options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gravity_falls_message.rb', line 6 def self.decode , cipher, ={} if cipher != 'binary' = cipher == 'a1z26' ? .split(/( |\W)/) : .split('') end # raise something if cipher == 'vigenere' && options[:key].nil? case cipher when 'a1z26' then Cipher.a1z26() when 'atbash' then Cipher.atbash() when 'binary' then Cipher.binary() when 'caesar' then Cipher.caesar(, ) when 'rotated_caesar' then Cipher.rotated_caesar(, ) when 'vigenere' then Cipher.vigenere(, ) end end |
.encode(message, cipher, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gravity_falls_message.rb', line 21 def self.encode , cipher, ={} = .split(//) if cipher != 'binary' case cipher when 'a1z26' then Cipher.a1z26(, true) when 'atbash' then Cipher.atbash(, true) when 'binary' then Cipher.binary(, true) when 'caesar' then Cipher.caesar(, .merge(encode: true)) when 'vigenere' then Cipher.vigenere(, .merge(encode: true)) end end |