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
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#casemap ⇒ Object
Returns the casemap of the receiver, by looking at the bound.
-
#downcase ⇒ Object
Up/downcasing something that includes this module returns its Up/downcased to_s form.
-
#fits_with_server_and_casemap?(opts = {}) ⇒ Boolean
This is an auxiliary method: it returns true if the receiver fits the server and casemap specified in opts, false otherwise.
-
#init_server_or_casemap(opts = {}) ⇒ Object
This method initializes the instance variables @server and @casemap according to the values of the hash keys :server and :casemap in opts.
-
#irc_downcase(cmap = casemap) ⇒ Object
We allow up/downcasing with a different casemap.
-
#irc_upcase(cmap = casemap) ⇒ Object
We allow up/downcasing with a different casemap.
-
#server_and_casemap ⇒ Object
Returns a hash with the current @server and @casemap as values of :server and :casemap.
-
#upcase ⇒ Object
Up/downcasing something that includes this module returns its Up/downcased to_s form.
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
183 184 185 |
# File 'lib/rbot/irc.rb', line 183 def server @server end |
Instance Method Details
#casemap ⇒ Object
Returns the casemap of the receiver, by looking at the bound
222 223 224 225 |
# File 'lib/rbot/irc.rb', line 222 def casemap return @server.casemap if defined?(@server) and @server return @casemap end |
#downcase ⇒ Object
Up/downcasing something that includes this module returns its Up/downcased to_s form
246 247 248 |
# File 'lib/rbot/irc.rb', line 246 def downcase self.irc_downcase end |
#fits_with_server_and_casemap?(opts = {}) ⇒ Boolean
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 '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 |
#init_server_or_casemap(opts = {}) ⇒ Object
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 '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 |
#irc_downcase(cmap = casemap) ⇒ Object
We allow up/downcasing with a different casemap
239 240 241 |
# File 'lib/rbot/irc.rb', line 239 def irc_downcase(cmap=casemap) self.to_s.irc_downcase(cmap) end |
#irc_upcase(cmap = casemap) ⇒ Object
We allow up/downcasing with a different casemap
252 253 254 |
# File 'lib/rbot/irc.rb', line 252 def irc_upcase(cmap=casemap) self.to_s.irc_upcase(cmap) end |
#server_and_casemap ⇒ Object
Returns a hash with the current @server and @casemap as values of :server and :casemap
230 231 232 233 234 235 |
# 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 |
#upcase ⇒ Object
Up/downcasing something that includes this module returns its Up/downcased to_s form
259 260 261 |
# File 'lib/rbot/irc.rb', line 259 def upcase self.irc_upcase end |