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:

  • *!*@* refers to everybody
  • *!someuser@somehost refers to user someuser on host somehost regardless of the nick used.

Methods

<=>   ==   ===   downcased   full_downcase   full_irc_downcase   fullform   generalize   has_irc_glob?   host=   ident=   inspect   matches?   new   nick=   replace   to_irc_netmask   to_irc_user   to_s   to_str   user=  

Included Modules

ServerOrCasemap

External Aliases

user -> ident

Attributes

host  [R] 
nick  [R] 
user  [R] 

Public Class methods

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

Public Instance methods

Sorting is done via the fullform

Equality: two Netmasks are equal if they downcase to the same thing

TODO we may want it to try other.to_irc_netmask

Case equality. Checks if arg matches self

This method returns a new Netmask which is the fully downcased version of the receiver

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.

ident=(newuser)

Alias for user=

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.

We can replace everything at once with data from another Netmask

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)

A Netmask is easily converted to a String for the usual representation. We skip the user or host parts if they are "*", unless we‘ve been asked for the full form

to_str()

Alias for fullform

This method changes the user of the Netmask, defaulting to the generic glob pattern if the result is the null string.

[Validate]