module Irc::ServerOrCasemap
This module is included by all classes that are either bound to a server or should have a casemap.
Attributes
Public Instance Methods
Source
# File lib/rbot/irc.rb, line 222 def casemap return @server.casemap if defined?(@server) and @server return @casemap end
Returns the casemap of the receiver, by looking at the bound @server (if possible) or at the @casemap otherwise
Source
# File lib/rbot/irc.rb, line 246 def downcase self.irc_downcase end
Up/downcasing something that includes this module returns its Up/downcased to_s form
Source
# File lib/rbot/irc.rb, line 206 def fits_with_server_and_casemap?(opts={}) srv = opts.fetch(:server, nil) cmap = opts.fetch(:casemap, nil) cmap = cmap.to_irc_casemap unless cmap.nil? if srv.nil? return true if cmap.nil? or cmap == casemap else return true if srv == @server and (cmap.nil? or cmap == casemap) end return false end
This is an auxiliary method: it returns true if the receiver fits the server and casemap specified in opts, false otherwise.
Source
# File lib/rbot/irc.rb, line 188 def init_server_or_casemap(opts={}) @server = opts.fetch(:server, nil) raise TypeError, "#{@server} is not a valid Irc::Server" if @server and not @server.kind_of?(Server) @casemap = opts.fetch(:casemap, nil) if @server if @casemap @server.casemap.must_be(@casemap) @casemap = nil end else @casemap = (@casemap || 'rfc1459').to_irc_casemap end end
This method initializes the instance variables @server and @casemap according to the values of the hash keys :server and :casemap in opts
Source
# File lib/rbot/irc.rb, line 239 def irc_downcase(cmap=casemap) self.to_s.irc_downcase(cmap) end
We allow up/downcasing with a different casemap
Source
# File lib/rbot/irc.rb, line 252 def irc_upcase(cmap=casemap) self.to_s.irc_upcase(cmap) end
We allow up/downcasing with a different casemap
Source
# File lib/rbot/irc.rb, line 230 def server_and_casemap h = {} h[:server] = @server if defined?(@server) and @server h[:casemap] = @casemap if defined?(@casemap) and @casemap return h end
Returns a hash with the current @server and @casemap as values of :server and :casemap
Source
# File lib/rbot/irc.rb, line 259 def upcase self.irc_upcase end
Up/downcasing something that includes this module returns its Up/downcased to_s form