A NetmaskList is an ArrayOf Netmask
s
Create a new NetmaskList, optionally filling it with the elements from the Array argument fed to it.
# File lib/rbot/irc.rb, line 872 def initialize(ar=[]) super(Netmask, ar) end
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?)
# 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