Class: Cryptogram
- Inherits:
-
Object
- Object
- Cryptogram
- Defined in:
- lib/cryptograms/cryptogram.rb
Constant Summary collapse
- ALPHABET =
(?A..?Z).to_a.map(&:freeze).freeze
Instance Attribute Summary collapse
-
#cyphertext ⇒ Object
readonly
Returns the value of attribute cyphertext.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#plaintext ⇒ Object
readonly
Returns the value of attribute plaintext.
Instance Method Summary collapse
-
#cypher ⇒ Object
Randomize until no cyphertext replacement is the same as the original letter.
-
#initialize(plaintext) ⇒ Cryptogram
constructor
A new instance of Cryptogram.
Constructor Details
#initialize(plaintext) ⇒ Cryptogram
Returns a new instance of Cryptogram.
5 6 7 8 |
# File 'lib/cryptograms/cryptogram.rb', line 5 def initialize plaintext @plaintext = plaintext.upcase @cyphertext = @plaintext.tr ALPHABET.join, cypher.join end |
Instance Attribute Details
#cyphertext ⇒ Object (readonly)
Returns the value of attribute cyphertext.
2 3 4 |
# File 'lib/cryptograms/cryptogram.rb', line 2 def cyphertext @cyphertext end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
2 3 4 |
# File 'lib/cryptograms/cryptogram.rb', line 2 def key @key end |
#plaintext ⇒ Object (readonly)
Returns the value of attribute plaintext.
2 3 4 |
# File 'lib/cryptograms/cryptogram.rb', line 2 def plaintext @plaintext end |