module SimplyAES::Format
Implementations of SimplyAES::Format
are formatting helpers, used by SimplyAES::Cipher
to dump byte-strings and to load formatted byte-strings.
Public Class Methods
[](name)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/simply-aes/format.rb, line 25 def self.included(implementation) if (name = implementation.name) # @todo support alternate-paths short_name = name.split('::').last.downcase.to_sym self[short_name] = implementation end end
Public Instance Methods
dump(bytestring)
click to toggle source
@param bytestring [String] @return formatted [String]
Calls superclass method
# File lib/simply-aes/format.rb, line 18 def dump(bytestring) return super if defined?(super) fail(NotImplementedError) end
load(formatted)
click to toggle source
@param formatted [String] @return bytestring [String]
Calls superclass method
# File lib/simply-aes/format.rb, line 11 def load(formatted) return super if defined?(super) fail(NotImplementedError) end