Class: Cinch::ISupport
- Inherits:
-
Hash
- Object
- Hash
- Cinch::ISupport
- Defined in:
- lib/cinch/i_support.rb
Overview
This class exposes parsed ISUPPORT information of the IRC network.
Constant Summary collapse
- @@mappings =
{ %w[PREFIX] => lambda { |v| modes, prefixes = v.match(/^\((.+)\)(.+)$/)[1..2] h = {} modes.chars.each_with_index do |c, i| h[c] = prefixes[i] end h }, %w[CHANTYPES] => lambda { |v| v.chars }, %w[CHANMODES] => lambda { |v| h = {} h["A"], h["B"], h["C"], h["D"] = v.split(",").map { |l| l.chars } h }, %w[MODES MAXCHANNELS NICKLEN MAXBANS TOPICLEN KICKLEN CHANNELLEN CHIDLEN SILENCE AWAYLEN MAXTARGETS WATCH MONITOR] => lambda { |v| v.to_i }, %w[CHANLIMIT MAXLIST IDCHAN] => lambda { |v| h = {} v.split(",").each do |pair| args, num = pair.split(":") args.chars.each do |arg| h[arg] = num.to_i end end h }, %w[TARGMAX] => lambda { |v| h = {} v.split(",").each do |pair| name, value = pair.split(":") h[name] = value.to_i end h }, %w[NETWORK] => lambda { |v| v }, %w[STATUSMSG] => lambda { |v| v.chars }, %w[CASEMAPPING] => lambda { |v| v.to_sym }, %w[ELIST] => lambda { |v| v.chars } # TODO STD }
Instance Method Summary collapse
-
#initialize(*args) ⇒ ISupport
constructor
A new instance of ISupport.
- #parse(*options) ⇒ void private
Constructor Details
#initialize(*args) ⇒ ISupport
Returns a new instance of ISupport.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/cinch/i_support.rb', line 54 def initialize(*args) super # by setting most numeric values to "Infinity", we let the # server truncate messages and lists while at the same time # allowing the use of strictness=:strict for servers that don't # support ISUPPORT (hopefully none, anyway) self["PREFIX"] = {"o" => "@", "v" => "+"} self["CHANTYPES"] = ["#"] self["CHANMODES"] = { "A" => ["b"], "B" => ["k"], "C" => ["l"], "D" => %w[i m n p s t r] } self["MODES"] = 1 self["NICKLEN"] = Float::INFINITY self["MAXBANS"] = Float::INFINITY self["TOPICLEN"] = Float::INFINITY self["KICKLEN"] = Float::INFINITY self["CHANNELLEN"] = Float::INFINITY self["CHIDLEN"] = 5 self["AWAYLEN"] = Float::INFINITY self["MAXTARGETS"] = 1 self["MAXCHANNELS"] = Float::INFINITY # deprecated self["CHANLIMIT"] = {"#" => Float::INFINITY} self["STATUSMSG"] = [] self["CASEMAPPING"] = :rfc1459 self["ELIST"] = [] self["MONITOR"] = 0 end |
Instance Method Details
#parse(*options) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/cinch/i_support.rb', line 88 def parse(*) .each do |option| name, value = option.split("=") if value proc = @@mappings.find { |key, _| key.include?(name) } self[name] = (proc && proc[1].call(value)) || value else self[name] = true end end end |