Module: Ciphers
- Defined in:
- lib/ciphers.rb,
lib/ciphers/autokey.rb,
lib/ciphers/version.rb,
lib/ciphers/vigenere.rb
Defined Under Namespace
Classes: Autokey, Vigenere
Constant Summary
collapse
- LATIN =
('A'..'Z').to_a
- VERSION =
"0.2.0"
Class Method Summary
collapse
Class Method Details
.alphabet_from(string) ⇒ Object
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/ciphers.rb', line 8
def self.alphabet_from(string)
raise ArgumentError.new("Argument must be at most #{LATIN.length} characters long") unless string.length <= 26
chars = string.upcase.chars
raise ArgumentError.new("Argument must not contain duplicate letters") unless chars.uniq == chars
if chars.length < 26
chars + (LATIN - chars)
else
chars
end
end
|