Sha256: 846ee8da1cebf5962e636307806e0e91abb440cb12e63e96a09dd943f621b343

Contents?: true

Size: 627 Bytes

Versions: 3

Compression:

Stored size: 627 Bytes

Contents

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

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

    def initialize
      @packets = []
    end

    def add packet, type
      packet = case type
      when :received then Received.new packet
      when :sent     then Sent.new packet
      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

3 entries across 3 versions & 1 rubygems

Version Path
packet_via_dmem-0.0.6 lib/packet_via_dmem/packets.rb
packet_via_dmem-0.0.5 lib/packet_via_dmem/packets.rb
packet_via_dmem-0.0.4 lib/packet_via_dmem/packets.rb