Class: Key::SKey

Inherits:
Key
  • Object
show all
Defined in:
lib/key/skey.rb

Overview

SKey

class for simple substitution keys

See en.wikipedia.org/wiki/Substitution_cipher

Direct Known Subclasses

Caesar, Playfair, SCKey, SQKey, Wheatstone

Constant Summary

BASE =
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (SKey) initialize(key)

Returns a new instance of SKey



24
25
26
27
28
# File 'lib/key/skey.rb', line 24

def initialize(key)
  super(key)
  @alpha = Hash.new
  @ralpha = Hash.new
end

Instance Attribute Details

- (Object) alpha (readonly)

Returns the value of attribute alpha



22
23
24
# File 'lib/key/skey.rb', line 22

def alpha
  @alpha
end

- (Object) ralpha (readonly)

Returns the value of attribute ralpha



22
23
24
# File 'lib/key/skey.rb', line 22

def ralpha
  @ralpha
end

Instance Method Details

- (Object) decode(c)

decode



38
39
40
# File 'lib/key/skey.rb', line 38

def decode(c)
  @ralpha[c] || c
end

- (Object) encode(c)

encode



32
33
34
# File 'lib/key/skey.rb', line 32

def encode(c)
  @alpha[c] || c
end