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.
1198 1199 1200 1201 1202 |
# File 'lib/mockserver/models.rb', line 1198 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.
1196 1197 1198 |
# File 'lib/mockserver/models.rb', line 1196 def binary @binary end |
#delay ⇒ Object
Returns the value of attribute delay.
1196 1197 1198 |
# File 'lib/mockserver/models.rb', line 1196 def delay @delay end |
#text ⇒ Object
Returns the value of attribute text.
1196 1197 1198 |
# File 'lib/mockserver/models.rb', line 1196 def text @text end |
Class Method Details
.from_hash(data) ⇒ Object
1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 |
# File 'lib/mockserver/models.rb', line 1212 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
1204 1205 1206 1207 1208 1209 1210 |
# File 'lib/mockserver/models.rb', line 1204 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 |