Class: Ransposition::Cipher

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

Class Method Summary collapse

Class Method Details

.randomObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ransposition.rb', line 8

def self.random
  num = 0

  print "  Message >> "
  message = gets.chomp

  size    = message.length * 2

  size.times do
    message = message.split("").shuffle.join.upcase.tr "A B C D E
                                                        F G H I J
                                                        K L M N O
                                                        P Q R S T
                                                        U V W X Y
                                                        Z",

                                                       "N O P Q R
                                                        S T U V W
                                                        X Y Z A B
                                                        C D E F G
                                                        H I J K L
                                                        M"

    puts "Result #{num}: #{message}"

    num += 1
  end
end