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.
1420 1421 1422 1423 1424 |
# File 'lib/mockserver/models.rb', line 1420 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.
1418 1419 1420 |
# File 'lib/mockserver/models.rb', line 1418 def binary @binary end |
#delay ⇒ Object
Returns the value of attribute delay.
1418 1419 1420 |
# File 'lib/mockserver/models.rb', line 1418 def delay @delay end |
#text ⇒ Object
Returns the value of attribute text.
1418 1419 1420 |
# File 'lib/mockserver/models.rb', line 1418 def text @text end |
Class Method Details
.from_hash(data) ⇒ Object
1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 |
# File 'lib/mockserver/models.rb', line 1434 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
1426 1427 1428 1429 1430 1431 1432 |
# File 'lib/mockserver/models.rb', line 1426 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 |