Class: TTTLS13::Message::Extension::SupportedGroups
- Inherits:
-
Object
- Object
- TTTLS13::Message::Extension::SupportedGroups
- Defined in:
- lib/tttls1.3/message/extension/supported_groups.rb
Instance Attribute Summary collapse
-
#extension_type ⇒ Object
readonly
Returns the value of attribute extension_type.
-
#named_group_list ⇒ Object
readonly
Returns the value of attribute named_group_list.
Class Method Summary collapse
-
.deserialize(binary) ⇒ TTTLS13::Message::Extension::SupportedGroups?
rubocop: disable Metrics/CyclomaticComplexity.
Instance Method Summary collapse
-
#initialize(named_group_list) ⇒ SupportedGroups
constructor
A new instance of SupportedGroups.
- #serialize ⇒ String
Constructor Details
#initialize(named_group_list) ⇒ SupportedGroups
Returns a new instance of SupportedGroups.
15 16 17 18 19 20 |
# File 'lib/tttls1.3/message/extension/supported_groups.rb', line 15 def initialize(named_group_list) @extension_type = ExtensionType::SUPPORTED_GROUPS @named_group_list = named_group_list || [] raise Error::ErrorAlerts, :internal_error \ if @named_group_list.empty? || @named_group_list.length >= 2**15 - 1 end |
Instance Attribute Details
#extension_type ⇒ Object (readonly)
Returns the value of attribute extension_type.
9 10 11 |
# File 'lib/tttls1.3/message/extension/supported_groups.rb', line 9 def extension_type @extension_type end |
#named_group_list ⇒ Object (readonly)
Returns the value of attribute named_group_list.
10 11 12 |
# File 'lib/tttls1.3/message/extension/supported_groups.rb', line 10 def named_group_list @named_group_list end |
Class Method Details
.deserialize(binary) ⇒ TTTLS13::Message::Extension::SupportedGroups?
rubocop: disable Metrics/CyclomaticComplexity
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/tttls1.3/message/extension/supported_groups.rb', line 35 def self.deserialize(binary) raise Error::ErrorAlerts, :internal_error if binary.nil? return nil if binary.length < 2 nglist_len = Convert.bin2i(binary.slice(0, 2)) i = 2 named_group_list = [] while i < nglist_len + 2 return nil if i + 2 > binary.length named_group_list << binary.slice(i, 2) i += 2 end return nil unless i == binary.length && nglist_len + 2 == binary.length SupportedGroups.new(named_group_list) end |
Instance Method Details
#serialize ⇒ String
23 24 25 26 27 |
# File 'lib/tttls1.3/message/extension/supported_groups.rb', line 23 def serialize binary = @named_group_list.join.prefix_uint16_length @extension_type + binary.prefix_uint16_length end |