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.
19 20 21 |
# File 'lib/cucumber/wire_support/wire_packet.rb', line 19 def initialize(, params = nil) @message, @params = , params end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
17 18 19 |
# File 'lib/cucumber/wire_support/wire_packet.rb', line 17 def @message end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
17 18 19 |
# File 'lib/cucumber/wire_support/wire_packet.rb', line 17 def params @params end |
Class Method Details
.parse(raw) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/cucumber/wire_support/wire_packet.rb', line 9 def parse(raw) attributes = MultiJson.load(raw.strip) = attributes[0] params = attributes[1] new(, params) end |
Instance Method Details
#handle_with(handler) ⇒ Object
29 30 31 |
# File 'lib/cucumber/wire_support/wire_packet.rb', line 29 def handle_with(handler) handler.send("handle_#{@message}", @params) end |
#to_json ⇒ Object
23 24 25 26 27 |
# File 'lib/cucumber/wire_support/wire_packet.rb', line 23 def to_json packet = [@message] packet << @params if @params packet.to_json end |