Class | Irc::Netmask |
In: |
lib/rbot/irc.rb
|
Parent: | Object |
A Netmask identifies each user by collecting its nick, username and hostname in the form nick!user@host
Netmasks can also contain glob patterns in any of their components; in this form they are used to refer to more than a user or to a user appearing under different forms.
Example:
user | -> | ident |
host | [R] | |
nick | [R] | |
user | [R] |
Create a new Netmask from string str, which must be in the form nick!user@host
It is possible to specify a server or a casemap in the optional Hash: these are used to associate the Netmask with the given server and to set its casemap: if a server is specified and a casemap is not, the server‘s casemap is used. If both a server and a casemap are specified, the casemap must match the server‘s casemap or an exception will be raised.
Empty nick, user or host are converted to the generic glob pattern
Equality: two Netmasks are equal if they downcase to the same thing
TODO we may want it to try other.to_irc_netmask
full_downcase() will return the fullform downcased according to the User‘s own casemap
This method downcases the fullform of the netmask. While this may not be significantly different from the downcase() method provided by the ServerOrCasemap mixin, it‘s significantly different for Netmask subclasses such as User whose simple downcasing uses the nick only.
This method checks if a Netmask is definite or not, by seeing if any of its components are defined by globs
This method changes the hostname of the Netmask, defaulting to the generic glob pattern if the result is the null string.
Inspection of a Netmask reveals the server it‘s bound to (if there is one), its casemap and the nick, user and host part
This method is used to match the current Netmask against another one
The method returns true if each component of the receiver matches the corresponding component of the argument. By matching here we mean that any netmask described by the receiver is also described by the argument.
In this sense, matching is rather simple to define in the case when the receiver has no globs: it is just necessary to check if the argument describes the receiver, which can be done by matching it against the argument converted into an IRC Regexp (see String#to_irc_regexp).
The situation is also easy when the receiver has globs and the argument doesn‘t, since in this case the result is false.
The more complex case in which both the receiver and the argument have globs is not handled yet.
This method changes the nick of the Netmask, defaulting to the generic glob pattern if the result is the null string.
Converts the receiver into a Netmask with the given (optional) server/casemap association. We return self unless a conversion is needed (different casemap/server)
Subclasses of Netmask will return a new Netmask, using full_downcase
Converts the receiver into a User with the given (optional) server/casemap association. We return self unless a conversion is needed (different casemap/server)
This method changes the user of the Netmask, defaulting to the generic glob pattern if the result is the null string.