Class: MockServer::WebSocketMessage
- Inherits:
-
Object
- Object
- MockServer::WebSocketMessage
- Defined in:
- lib/mockserver/models.rb
Instance Attribute Summary collapse
-
#binary ⇒ Object
Returns the value of attribute binary.
-
#delay ⇒ Object
Returns the value of attribute delay.
-
#text ⇒ Object
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(text: nil, binary: nil, delay: nil) ⇒ WebSocketMessage
constructor
A new instance of WebSocketMessage.
- #to_h ⇒ Object
Constructor Details
#initialize(text: nil, binary: nil, delay: nil) ⇒ WebSocketMessage
Returns a new instance of WebSocketMessage.
1086 1087 1088 1089 1090 |
# File 'lib/mockserver/models.rb', line 1086 def initialize(text: nil, binary: nil, delay: nil) @text = text @binary = binary @delay = delay end |
Instance Attribute Details
#binary ⇒ Object
Returns the value of attribute binary.
1084 1085 1086 |
# File 'lib/mockserver/models.rb', line 1084 def binary @binary end |
#delay ⇒ Object
Returns the value of attribute delay.
1084 1085 1086 |
# File 'lib/mockserver/models.rb', line 1084 def delay @delay end |
#text ⇒ Object
Returns the value of attribute text.
1084 1085 1086 |
# File 'lib/mockserver/models.rb', line 1084 def text @text end |
Class Method Details
.from_hash(data) ⇒ Object
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 |
# File 'lib/mockserver/models.rb', line 1100 def self.from_hash(data) return nil if data.nil? binary_data = data['binary'] binary = binary_data ? Base64.strict_decode64(binary_data) : nil new( text: data['text'], binary: binary, delay: Delay.from_hash(data['delay']) ) end |
Instance Method Details
#to_h ⇒ Object
1092 1093 1094 1095 1096 1097 1098 |
# File 'lib/mockserver/models.rb', line 1092 def to_h result = {} result['text'] = @text unless @text.nil? result['binary'] = Base64.strict_encode64(@binary) unless @binary.nil? result['delay'] = @delay.to_h if @delay result end |