Class: InternetHakai::ClientQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/internethakai/client_queue.rb

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ ClientQueue

Returns a new instance of ClientQueue.



3
4
5
6
7
# File 'lib/internethakai/client_queue.rb', line 3

def initialize size
    @queue = []
    @size = size
    @ptr = size
end

Instance Method Details

#add(cl) ⇒ Object



23
24
25
# File 'lib/internethakai/client_queue.rb', line 23

def add cl
    @queue << cl
end

#collect(cl) ⇒ Object



19
20
21
22
# File 'lib/internethakai/client_queue.rb', line 19

def collect cl
    @ptr += 1
    @queue << cl
end

#empty?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/internethakai/client_queue.rb', line 8

def empty?
    @ptr == 0
end

#getObject



11
12
13
14
15
16
17
18
# File 'lib/internethakai/client_queue.rb', line 11

def get
    if @ptr == 0
        nil
    else
        @ptr -= 1
        @queue.shift
    end
end