Class Irc::NetmaskList
In: lib/rbot/irc.rb
Parent: ArrayOf
BasicUserMessage JoinMessage NamesMessage WhoisMessage ModeChangeMessage KickMessage MotdMessage QuitMessage BanlistMessage UserMessage NoSuchTargetMessage TopicMessage NickMessage WelcomeMessage UnknownMessage InviteMessage PartMessage NetmaskList UserList ArrayOf ChannelList Netmask User\n[lib/rbot/botuser.rb\nlib/rbot/irc.rb] Channel Singleton RfcCasemap StrictRfcCasemap AsciiCasemap Casemap PrivMessage NoticeMessage TokyoCabinet::BDB CIBDB Btree CIBtree Socket MessageQueue QueueRing Client DBHash\n[lib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] DBTree\n[lib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] Server NetmaskDb Bot\n[lib/rbot/botuser.rb\nlib/rbot/config.rb\nlib/rbot/ircbot.rb\nlib/rbot/language.rb\nlib/rbot/message.rb\nlib/rbot/messagemapper.rb\nlib/rbot/plugins.rb\nlib/rbot/rbotconfig.rb\nlib/rbot/registry/bdb.rb\nlib/rbot/registry/tc.rb] lib/rbot/ircsocket.rb lib/rbot/rfc2812.rb lib/rbot/registry/tc.rb lib/rbot/irc.rb lib/rbot/maskdb.rb lib/rbot/message.rb lib/rbot/messagemapper.rb lib/rbot/botuser.rb lib/rbot/registry/tc.rb (null) BotConfig PKGConfig ServerOrCasemap Irc dot/m_35_0.png

Methods

[]   new  

Public Class methods

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

[Source]

     # File lib/rbot/irc.rb, line 872
872:     def initialize(ar=[])
873:       super(Netmask, ar)
874:     end

Public Instance methods

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?)

[Source]

     # File lib/rbot/irc.rb, line 882
882:     def [](*args)
883:       if args.length == 1
884:         case args[0]
885:         when Netmask
886:           self.find { |mask|
887:             mask.matches?(args[0])
888:           }
889:         when String
890:           self.find { |mask|
891:             mask.matches?(args[0].to_irc_netmask(:casemap => mask.casemap))
892:           }
893:         when Regexp
894:           self.find { |mask|
895:             mask.fullform =~ args[0]
896:           }
897:         else
898:           super(*args)
899:         end
900:       else
901:         super(*args)
902:       end
903:     end

[Validate]