Module | Irc::ServerOrCasemap |
In: |
lib/rbot/irc.rb
|
This module is included by all classes that are either bound to a server or should have a casemap.
server | [R] |
Up/downcasing something that includes this module returns its Up/downcased to_s form
# File lib/rbot/irc.rb, line 246 246: def downcase 247: self.irc_downcase 248: end
This is an auxiliary method: it returns true if the receiver fits the server and casemap specified in opts, false otherwise.
# File lib/rbot/irc.rb, line 206 206: def fits_with_server_and_casemap?(opts={}) 207: srv = opts.fetch(:server, nil) 208: cmap = opts.fetch(:casemap, nil) 209: cmap = cmap.to_irc_casemap unless cmap.nil? 210: 211: if srv.nil? 212: return true if cmap.nil? or cmap == casemap 213: else 214: return true if srv == @server and (cmap.nil? or cmap == casemap) 215: end 216: return false 217: end
This method initializes the instance variables @server and @casemap according to the values of the hash keys :server and :casemap in opts
# File lib/rbot/irc.rb, line 188 188: def init_server_or_casemap(opts={}) 189: @server = opts.fetch(:server, nil) 190: raise TypeError, "#{@server} is not a valid Irc::Server" if @server and not @server.kind_of?(Server) 191: 192: @casemap = opts.fetch(:casemap, nil) 193: if @server 194: if @casemap 195: @server.casemap.must_be(@casemap) 196: @casemap = nil 197: end 198: else 199: @casemap = (@casemap || 'rfc1459').to_irc_casemap 200: end 201: end
Returns a hash with the current @server and @casemap as values of :server and :casemap
# File lib/rbot/irc.rb, line 230 230: def server_and_casemap 231: h = {} 232: h[:server] = @server if defined?(@server) and @server 233: h[:casemap] = @casemap if defined?(@casemap) and @casemap 234: return h 235: end