Module: Rot135

Defined in:
lib/rot135.rb,
lib/rot135/version.rb

Overview

Implements ROT13 (see wikipedia.org/wiki/ROT13 for details). Call with ‘Rot135.rot(string)`.

Defined Under Namespace

Classes: UnknownSpecifierError

Constant Summary collapse

VERSION =
'0.0.3'

Class Method Summary collapse

Class Method Details

.rot(text, specifiers: [:rot13]) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rot135.rb', line 11

def self.rot(text, specifiers: [:rot13])
  specifiers.each do |option|
    case option
    when :rot5
      text = text.tr('0123456789', '5678901234')
    when :rot13
      text = text.tr('A-Za-z', 'N-ZA-Mn-za-m')
    else
      raise UnknownSpecifierError, "Unrecognised specifier '#{option} found"
    end
  end
  text
end