Class: Crypt::Rot13
- Inherits:
-
String
- Object
- String
- Crypt::Rot13
- Defined in:
- lib/crypt/rot13.rb
Overview
The Rot13 class encapsulates methods governing character rotation.
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
The version of the crypt-rot13 library.
'1.2.0'.freeze
Instance Method Summary collapse
-
#initialize(str = '', degree = 13) ⇒ Rot13
constructor
Returns a new Rot13 object.
-
#rotate(degree) ⇒ Object
Rotates the Crypt::Rot13 object by
degree.
Constructor Details
#initialize(str = '', degree = 13) ⇒ Rot13
Returns a new Rot13 object. The object is a string with the letters each rotated by degree.
You cannot use a multiple of 26 as the degree or a Rot13::Error will be raised. So, your days of double rot13 encryption are over.
19 20 21 22 |
# File 'lib/crypt/rot13.rb', line 19 def initialize(str='', degree=13) str = rotate_string(str, degree) unless str.empty? super(str) end |
Instance Method Details
#rotate(degree) ⇒ Object
Rotates the Crypt::Rot13 object by degree.
26 27 28 |
# File 'lib/crypt/rot13.rb', line 26 def rotate(degree) rotate_string(self, degree) end |