Sha256: dc7940843fce55b1a704daa991dbb0b03ff6b560b9f162c276fff7793b1a625f

Contents?: true

Size: 718 Bytes

Versions: 3

Compression:

Stored size: 718 Bytes

Contents

module Cucumber
  module WireSupport
    # Represents the packet of data sent over the wire as JSON data, containing
    # a message and a hash of arguments
    class WirePacket
      class << self
        def parse(raw)
          attributes = JSON.parse(raw.strip)
          message = attributes[0]
          params  = attributes[1]
          new(message, params)
        end
      end
      
      attr_reader :message, :params
      
      def initialize(message, params)
        @message, @params = message, params
      end
      
      def to_json
        [@message, @params].to_json
      end
      
      def handle_with(handler)
        handler.send("handle_#{@message}", @params)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cucumber-0.5.2 lib/cucumber/wire_support/wire_packet.rb
cucumber-0.5.1 lib/cucumber/wire_support/wire_packet.rb
cucumber-0.5.0 lib/cucumber/wire_support/wire_packet.rb