Class: Ircmad::WebSocket::Buffer

Inherits:
Object
  • Object
show all
Defined in:
lib/ircmad/web_socket/buffer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_max = 100) ⇒ Buffer

Returns a new instance of Buffer.



6
7
8
# File 'lib/ircmad/web_socket/buffer.rb', line 6

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(action, *args, &block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/ircmad/web_socket/buffer.rb', line 22

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

Instance Attribute Details

#aryObject (readonly)

Returns the value of attribute ary.



4
5
6
# File 'lib/ircmad/web_socket/buffer.rb', line 4

def ary
  @ary
end

#maxObject (readonly)

Returns the value of attribute max.



4
5
6
# File 'lib/ircmad/web_socket/buffer.rb', line 4

def max
  @max
end

Instance Method Details

#push(element) ⇒ Object Also known as: <<



10
11
12
13
14
15
# File 'lib/ircmad/web_socket/buffer.rb', line 10

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