class Cucumber::WireSupport::WirePacket

Represents the packet of data sent over the wire as JSON data, containing a message and a hash of arguments

Attributes

message[R]
params[R]

Public Class Methods

new(message, params = nil) click to toggle source
# File lib/cucumber/wire_support/wire_packet.rb, line 17
def initialize(message, params = nil)
  @message, @params = message, params
end
parse(raw) click to toggle source
# File lib/cucumber/wire_support/wire_packet.rb, line 7
def parse(raw)
  attributes = JSON.parse(raw.strip)
  message = attributes[0]
  params  = attributes[1]
  new(message, params)
end

Public Instance Methods

handle_with(handler) click to toggle source
# File lib/cucumber/wire_support/wire_packet.rb, line 27
def handle_with(handler)
  handler.send("handle_#{@message}", @params)
end
to_json() click to toggle source
# File lib/cucumber/wire_support/wire_packet.rb, line 21
def to_json
  packet = [@message]
  packet << @params if @params
  packet.to_json
end