Class: Irc::NetmaskList
Overview
A NetmaskList is an ArrayOf Netmask
s
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from ArrayOf
Instance Method Summary collapse
-
#[](*args) ⇒ Object
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?).
-
#initialize(ar = []) ⇒ NetmaskList
constructor
Create a new NetmaskList, optionally filling it with the elements from the Array argument fed to it.
Methods inherited from ArrayOf
#&, #+, #-, #<<, #concat, #downcase, #insert, #inspect, #push, #replace, #unshift, #valid?, #validate, #will_accept?, #|
Methods inherited from Array
#delete_one, #pick_one, #shuffle, #shuffle!
Constructor Details
#initialize(ar = []) ⇒ NetmaskList
Create a new NetmaskList, optionally filling it with the elements from the Array argument fed to it.
872 873 874 |
# File 'lib/rbot/irc.rb', line 872 def initialize(ar=[]) super(Netmask, ar) end |
Instance Method Details
#[](*args) ⇒ Object
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?)
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 |
# 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 |