class Nova::Starbound::Encryptor

An encryptor is used to encrypt the data in the exchange for the starbound protocol.

@abstract

Attributes

preference[R]

The preference for this encryptor. Used to sort the encryptors.

@return [Numeric]

options[R]

The options. These are mostly use internally.

@return [Hash<Symbol, Object>]

Public Class Methods

available?() click to toggle source

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
encryptor_name(name = nil) click to toggle source

@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
encryptors() click to toggle source

The encryptors that are defined.

@return [Array<Encryptor>]

# File lib/nova/starbound/encryptor.rb, line 51
def self.encryptors
  @encryptors ||= []
end
new() click to toggle source

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
plaintext?() click to toggle source

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
register!(preference) click to toggle source

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
sorted_encryptors() click to toggle source

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