Class: TTTLS13::Message::Alert
- Inherits:
-
Object
- Object
- TTTLS13::Message::Alert
- Defined in:
- lib/tttls1.3/message/alert.rb
Overview
rubocop: enable Layout/HashAlignment
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(level: nil, description:) ⇒ Alert
constructor
A new instance of Alert.
- #serialize ⇒ String
- #to_error ⇒ TTTLS13::Error::ErrorAlerts
Constructor Details
#initialize(level: nil, description:) ⇒ Alert
Returns a new instance of Alert.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/tttls1.3/message/alert.rb', line 49 def initialize(level: nil, description:) @level = level @description = description if @level.nil? && (@description == ALERT_DESCRIPTION[:user_canceled] || @description == ALERT_DESCRIPTION[:close_notify]) @level = AlertLevel::WARNING elsif @level.nil? @level = AlertLevel::FATAL end end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
45 46 47 |
# File 'lib/tttls1.3/message/alert.rb', line 45 def description @description end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
44 45 46 |
# File 'lib/tttls1.3/message/alert.rb', line 44 def level @level end |
Class Method Details
.deserialize(binary) ⇒ TTTLS13::Message::Alert
70 71 72 73 74 75 76 77 |
# File 'lib/tttls1.3/message/alert.rb', line 70 def self.deserialize(binary) raise Error::ErrorAlerts, :internal_error if binary.nil? raise Error::ErrorAlerts, :decode_error unless binary.length == 2 level = binary[0] description = binary[1] Alert.new(level: level, description: description) end |
Instance Method Details
#serialize ⇒ String
61 62 63 |
# File 'lib/tttls1.3/message/alert.rb', line 61 def serialize @level + @description end |
#to_error ⇒ TTTLS13::Error::ErrorAlerts
80 81 82 83 |
# File 'lib/tttls1.3/message/alert.rb', line 80 def to_error desc = ALERT_DESCRIPTION.invert[@description] Error::ErrorAlerts.new(desc) end |