Sha256: 77d3d33ede4a86b97eaed18198fad5ff49568b3d008e9f6f262baa4054c21690

Contents?: true

Size: 529 Bytes

Versions: 1

Compression:

Stored size: 529 Bytes

Contents

class Ircmad
  class WebSocket
    class Buffer
      attr_reader :ary, :max

      def initialize(_max = 100)
        @max = _max
      end

      def push(element)
        if size > max
          shift
        end
        ary << element
      end
      alias_method :<<, :push

      def ary
        @ary ||= []
      end

      def method_missing(action, *args, &block)
        if ary.respond_to?(action.to_s)
          ary.send(action.to_s, *args, &block)
        else
          super
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ircmad-0.0.3 lib/ircmad/web_socket/buffer.rb