Class: Cucumber::WireSupport::WirePacket
- Defined in:
- lib/cucumber/wire_support/wire_packet.rb
Overview
Represents the packet of data sent over the wire as JSON data, containing a message and a hash of arguments
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
- #handle_with(handler) ⇒ Object
-
#initialize(message, params = nil) ⇒ WirePacket
constructor
A new instance of WirePacket.
- #to_json ⇒ Object
Constructor Details
#initialize(message, params = nil) ⇒ WirePacket
Returns a new instance of WirePacket.
17 18 19 |
# File 'lib/cucumber/wire_support/wire_packet.rb', line 17 def initialize(, params = nil) @message, @params = , params end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
15 16 17 |
# File 'lib/cucumber/wire_support/wire_packet.rb', line 15 def @message end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
15 16 17 |
# File 'lib/cucumber/wire_support/wire_packet.rb', line 15 def params @params end |
Class Method Details
.parse(raw) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/cucumber/wire_support/wire_packet.rb', line 7 def parse(raw) attributes = JSON.parse(raw.strip) = attributes[0] params = attributes[1] new(, params) end |
Instance Method Details
#handle_with(handler) ⇒ Object
27 28 29 |
# File 'lib/cucumber/wire_support/wire_packet.rb', line 27 def handle_with(handler) handler.send("handle_#{@message}", @params) end |
#to_json ⇒ Object
21 22 23 24 25 |
# File 'lib/cucumber/wire_support/wire_packet.rb', line 21 def to_json packet = [@message] packet << @params if @params packet.to_json end |