class Nova::Starbound::Encryptor
An encryptor is used to encrypt the data in the exchange for the starbound protocol.
@abstract
Attributes
The preference for this encryptor. Used to sort the encryptors.
@return [Numeric]
The options. These are mostly use internally.
@return [Hash<Symbol, Object>]
Public Class Methods
Whether or not this encryptor is available. Defaults to false.
@return [Boolean]
# File lib/nova/starbound/encryptor.rb, line 68 def self.available? false end
@overload encryptor_name
(name)
Sets the encryptor's name. Used for negotiation of encryption protocols. @param name [String] the name of the encryptor. @return [void]
@overload encryptor_name
Gets the encryptor's name. @return [String]
# File lib/nova/starbound/encryptor.rb, line 20 def self.encryptor_name(name = nil) if name @encryptor_name = name else @encryptor_name end end
The encryptors that are defined.
@return [Array<Encryptor>]
# File lib/nova/starbound/encryptor.rb, line 51 def self.encryptors @encryptors ||= [] end
Initialize the encryptor.
@raise [NotImplementedError] if {.available?} returns false.
# File lib/nova/starbound/encryptor.rb, line 89 def initialize @options = {} unless self.class.available? raise NotImplementedError, "#{self.class.encryptor_name} is not avialable!" end end
Returns whether or not this is a plaintext encryptor, or one equivalent. Defaults to false, so most encryptors shouldn’t have to overwrite this.
@return [Boolean]
# File lib/nova/starbound/encryptor.rb, line 77 def self.plaintext? false end
Registers a subclass with the Encryptor
class for use with the protocol.
@param preference [Numeric] a number that is used to sort the
encryptors by preference.
@return [void]
# File lib/nova/starbound/encryptor.rb, line 34 def self.register!(preference) @preference = preference Encryptor.encryptors.push(self) end
The encryptors, sorted by preference.
@return [Array<Encryptor>]
# File lib/nova/starbound/encryptor.rb, line 58 def self.sorted_encryptors encryptors.sort do |a, b| b.preference <=> a.preference end end