module Irc::ServerOrCasemap

This module is included by all classes that are either bound to a server or should have a casemap.

Attributes

server[R]

Public Instance Methods

casemap() click to toggle source

Returns the casemap of the receiver, by looking at the bound @server (if possible) or at the @casemap otherwise

# File lib/rbot/irc.rb, line 223
def casemap
  return @server.casemap if defined?(@server) and @server
  return @casemap
end
downcase() click to toggle source

Up/downcasing something that includes this module returns its Up/downcased to_s form

# File lib/rbot/irc.rb, line 247
def downcase
  self.irc_downcase
end
fits_with_server_and_casemap?(opts={}) click to toggle source

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 207
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
init_server_or_casemap(opts={}) click to toggle source

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
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
    warning 'casemap fallback to rfc1459 without hints, correct?'
    @casemap = (@casemap || 'rfc1459').to_irc_casemap
  end
end
irc_downcase(cmap=casemap) click to toggle source

We allow up/downcasing with a different casemap

# File lib/rbot/irc.rb, line 240
def irc_downcase(cmap=casemap)
  self.to_s.irc_downcase(cmap)
end
irc_upcase(cmap=casemap) click to toggle source

We allow up/downcasing with a different casemap

# File lib/rbot/irc.rb, line 253
def irc_upcase(cmap=casemap)
  self.to_s.irc_upcase(cmap)
end
server_and_casemap() click to toggle source

Returns a hash with the current @server and @casemap as values of :server and :casemap

# File lib/rbot/irc.rb, line 231
def server_and_casemap
  h = {}
  h[:server] = @server if defined?(@server) and @server
  h[:casemap] = @casemap if defined?(@casemap) and @casemap
  return h
end
upcase() click to toggle source

Up/downcasing something that includes this module returns its Up/downcased to_s form

# File lib/rbot/irc.rb, line 260
def upcase
  self.irc_upcase
end