Class Irc::QueueRing
In: lib/rbot/ircsocket.rb
Parent: Object
BasicUserMessage JoinMessage NamesMessage WhoisMessage ModeChangeMessage KickMessage MotdMessage QuitMessage BanlistMessage UserMessage NoSuchTargetMessage TopicMessage NickMessage WelcomeMessage UnknownMessage InviteMessage PartMessage NetmaskList UserList ArrayOf ChannelList Netmask User\n[lib/rbot/botuser.rb\nlib/rbot/irc.rb] Channel Singleton RfcCasemap StrictRfcCasemap AsciiCasemap Casemap PrivMessage NoticeMessage TokyoCabinet::BDB CIBDB Btree CIBtree Socket MessageQueue QueueRing Client DBHash\n[lib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] DBTree\n[lib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] Server NetmaskDb Bot\n[lib/rbot/botuser.rb\nlib/rbot/config.rb\nlib/rbot/ircbot.rb\nlib/rbot/language.rb\nlib/rbot/message.rb\nlib/rbot/messagemapper.rb\nlib/rbot/plugins.rb\nlib/rbot/rbotconfig.rb\nlib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] lib/rbot/ircsocket.rb lib/rbot/rfc2812.rb lib/rbot/registry/tc.rb lib/rbot/irc.rb lib/rbot/maskdb.rb lib/rbot/message.rb lib/rbot/messagemapper.rb lib/rbot/botuser.rb lib/rbot/registry/tc.rb (null) BotConfig PKGConfig ServerOrCasemap Irc dot/m_35_0.png

Methods

clear   empty?   length   new   next   push   shift   size  

Public Class methods

A QueueRing is implemented as an array with elements in the form [chan, [message1, message2, …] Note that the channel chan has no actual bearing with the channels to which messages will be sent

[Source]

    # File lib/rbot/ircsocket.rb, line 92
92:     def initialize
93:       @storage = Array.new
94:       @last_idx = -1
95:     end

Public Instance methods

[Source]

     # File lib/rbot/ircsocket.rb, line 97
 97:     def clear
 98:       @storage.clear
 99:       @last_idx = -1
100:     end

[Source]

     # File lib/rbot/ircsocket.rb, line 111
111:     def empty?
112:       @storage.empty?
113:     end

[Source]

     # File lib/rbot/ircsocket.rb, line 102
102:     def length
103:       len = 0
104:       @storage.each {|c|
105:         len += c[1].size
106:       }
107:       return len
108:     end

[Source]

     # File lib/rbot/ircsocket.rb, line 126
126:     def next
127:       if empty?
128:         warning "trying to access empty ring"
129:         return nil
130:       end
131:       save_idx = @last_idx
132:       @last_idx = (@last_idx + 1) % @storage.size
133:       mess = @storage[@last_idx][1].first
134:       @last_idx = save_idx
135:       return mess
136:     end

[Source]

     # File lib/rbot/ircsocket.rb, line 115
115:     def push(mess, chan)
116:       cmess = @storage.assoc(chan)
117:       if cmess
118:         idx = @storage.index(cmess)
119:         cmess[1] << mess
120:         @storage[idx] = cmess
121:       else
122:         @storage << [chan, [mess]]
123:       end
124:     end

[Source]

     # File lib/rbot/ircsocket.rb, line 138
138:     def shift
139:       if empty?
140:         warning "trying to access empty ring"
141:         return nil
142:       end
143:       @last_idx = (@last_idx + 1) % @storage.size
144:       mess = @storage[@last_idx][1].shift
145:       @storage.delete(@storage[@last_idx]) if @storage[@last_idx][1] == []
146:       return mess
147:     end
size()

Alias for length

[Validate]