Module: Irc::ServerOrCasemap
Overview
This module is included by all classes that are either bound to a server or should have a casemap.
Instance Attribute Summary (collapse)
-
- (Object) server
readonly
Returns the value of attribute server.
Instance Method Summary (collapse)
-
- (Object) casemap
Returns the casemap of the receiver, by looking at the bound.
-
- (Object) downcase
Up/downcasing something that includes this module returns its Up/downcased to_s form.
-
- (Boolean) fits_with_server_and_casemap?(opts = {})
This is an auxiliary method: it returns true if the receiver fits the server and casemap specified in opts, false otherwise.
-
- (Object) init_server_or_casemap(opts = {})
This method initializes the instance variables @server and @casemap according to the values of the hash keys :server and :casemap in opts.
-
- (Object) irc_downcase(cmap = casemap)
We allow up/downcasing with a different casemap.
-
- (Object) irc_upcase(cmap = casemap)
We allow up/downcasing with a different casemap.
-
- (Object) server_and_casemap
Returns a hash with the current @server and @casemap as values of :server and :casemap.
-
- (Object) upcase
Up/downcasing something that includes this module returns its Up/downcased to_s form.
Instance Attribute Details
- (Object) server (readonly)
Returns the value of attribute server
183 184 185 |
# File '/home/apoc/projects/ruby/rbot/lib/rbot/irc.rb', line 183 def server @server end |
Instance Method Details
- (Object) casemap
Returns the casemap of the receiver, by looking at the bound
222 223 224 225 |
# File '/home/apoc/projects/ruby/rbot/lib/rbot/irc.rb', line 222 def casemap return @server.casemap if defined?(@server) and @server return @casemap end |
- (Object) downcase
Up/downcasing something that includes this module returns its Up/downcased to_s form
246 247 248 |
# File '/home/apoc/projects/ruby/rbot/lib/rbot/irc.rb', line 246 def downcase self.irc_downcase end |
- (Boolean) fits_with_server_and_casemap?(opts = {})
This is an auxiliary method: it returns true if the receiver fits the server and casemap specified in opts, false otherwise.
206 207 208 209 210 211 212 213 214 215 216 217 |
# File '/home/apoc/projects/ruby/rbot/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 |
- (Object) init_server_or_casemap(opts = {})
This method initializes the instance variables @server and @casemap according to the values of the hash keys :server and :casemap in opts
188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File '/home/apoc/projects/ruby/rbot/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 |
- (Object) irc_downcase(cmap = casemap)
We allow up/downcasing with a different casemap
239 240 241 |
# File '/home/apoc/projects/ruby/rbot/lib/rbot/irc.rb', line 239 def irc_downcase(cmap=casemap) self.to_s.irc_downcase(cmap) end |
- (Object) irc_upcase(cmap = casemap)
We allow up/downcasing with a different casemap
252 253 254 |
# File '/home/apoc/projects/ruby/rbot/lib/rbot/irc.rb', line 252 def irc_upcase(cmap=casemap) self.to_s.irc_upcase(cmap) end |
- (Object) server_and_casemap
Returns a hash with the current @server and @casemap as values of :server and :casemap
230 231 232 233 234 235 |
# File '/home/apoc/projects/ruby/rbot/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 |
- (Object) upcase
Up/downcasing something that includes this module returns its Up/downcased to_s form
259 260 261 |
# File '/home/apoc/projects/ruby/rbot/lib/rbot/irc.rb', line 259 def upcase self.irc_upcase end |