Module: SimplyAES::Format
Overview
Implementations of SimplyAES::Format are formatting helpers, used by SimplyAES::Cipher to dump byte-strings and to load formatted byte-strings.
Defined Under Namespace
Modules: Base64, Bytes, Hex
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.[](name) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/simply-aes/format.rb', line 38
def self.[](name)
return name if name.is_a?(Module) && name <= self
@implementations.fetch(name) do
fail(ArgumentError, "Unknown format: #{name}")
end
end
|
.[]=(name, implementation) ⇒ Object
33
34
35
36
|
# File 'lib/simply-aes/format.rb', line 33
def self.[]=(name, implementation)
fail(ArgumentError, "not a #{self}") unless implementation <= self
@implementations[name] = implementation
end
|
.included(implementation) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/simply-aes/format.rb', line 25
def self.included(implementation)
if (name = implementation.name)
short_name = name.split('::').last.downcase.to_sym
self[short_name] = implementation
end
end
|
Instance Method Details
#dump(bytestring) ⇒ Object
18
19
20
21
|
# File 'lib/simply-aes/format.rb', line 18
def dump(bytestring)
return super if defined?(super)
fail(NotImplementedError)
end
|
#load(formatted) ⇒ Object
11
12
13
14
|
# File 'lib/simply-aes/format.rb', line 11
def load(formatted)
return super if defined?(super)
fail(NotImplementedError)
end
|