Sha256: 088ed8ac21e337c2f890f6ac51f011695ca4fd9d34abcd05651fab6e9cb90ef5

Contents?: true

Size: 672 Bytes

Versions: 4

Compression:

Stored size: 672 Bytes

Contents

require_relative 'packet'
require_relative 'received'
require_relative 'sent'

class PacketViaDMEM
  class Packets
    include Enumerable
    class InvalidType < Error; end

    def initialize debug
      @debug   = debug
      @packets = []
    end

    def add packet, type
      packet = case type
      when :received then Received.new packet, @debug
      when :sent     then Sent.new packet, @debug
      else raise InvalidType, "#{type} not valid packet type"
      end
      @packets << packet
    rescue Packet::NoPayload
    end

    def each &block
      @packets.each { |packet| block.call packet }
    end

    def size
      @packets.size
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
packet_via_dmem-0.0.12 lib/packet_via_dmem/packets.rb
packet_via_dmem-0.0.11 lib/packet_via_dmem/packets.rb
packet_via_dmem-0.0.10 lib/packet_via_dmem/packets.rb
packet_via_dmem-0.0.8 lib/packet_via_dmem/packets.rb