class Irc::NetmaskList

A NetmaskList is an ArrayOf Netmasks

Public Class Methods

new(ar=[]) click to toggle source

Create a new NetmaskList, optionally filling it with the elements from the Array argument fed to it.

Calls superclass method ArrayOf.new
# File lib/rbot/irc.rb, line 872
def initialize(ar=[])
  super(Netmask, ar)
end

Public Instance Methods

[](*args) click to toggle source

We enhance the [] method by allowing it to pick an element that matches a given Netmask, a String or a Regexp TODO take into consideration the opportunity to use select() instead of find(), and/or a way to let the user choose which one to take (second argument?)

Calls superclass method
# File lib/rbot/irc.rb, line 882
def [](*args)
  if args.length == 1
    case args[0]
    when Netmask
      self.find { |mask|
        mask.matches?(args[0])
      }
    when String
      self.find { |mask|
        mask.matches?(args[0].to_irc_netmask(:casemap => mask.casemap))
      }
    when Regexp
      self.find { |mask|
        mask.fullform =~ args[0]
      }
    else
      super(*args)
    end
  else
    super(*args)
  end
end