Class: ShiftCipher::Caesar
- Inherits:
-
Object
- Object
- ShiftCipher::Caesar
- Defined in:
- lib/shift_cipher/caesar.rb
Constant Summary collapse
- DEFAULT_OFFSET =
0- FIRST_UNICODE_CODEPOINT =
97- LAST_UNICODE_CODEPOINT =
123
Instance Attribute Summary collapse
-
#offset ⇒ Object
Returns the value of attribute offset.
Instance Method Summary collapse
- #decrypt(message) ⇒ Object
- #encrypt(message) ⇒ Object
-
#initialize(start = 0) ⇒ Caesar
constructor
A new instance of Caesar.
Constructor Details
#initialize(start = 0) ⇒ Caesar
Returns a new instance of Caesar.
10 11 12 |
# File 'lib/shift_cipher/caesar.rb', line 10 def initialize(start = 0) @offset = calculate_offset(start) end |
Instance Attribute Details
#offset ⇒ Object
Returns the value of attribute offset.
8 9 10 |
# File 'lib/shift_cipher/caesar.rb', line 8 def offset @offset end |
Instance Method Details
#decrypt(message) ⇒ Object
18 19 20 |
# File 'lib/shift_cipher/caesar.rb', line 18 def decrypt() shift(, -offset) end |
#encrypt(message) ⇒ Object
14 15 16 |
# File 'lib/shift_cipher/caesar.rb', line 14 def encrypt() shift(, offset) end |