Class: IRCSupport::Message::Numeric005
- Inherits:
-
Numeric
- Object
- IRCSupport::Message
- Numeric
- IRCSupport::Message::Numeric005
- Defined in:
- lib/ircsupport/message.rb
Constant Summary collapse
- @@isupport_mappings =
{ %w[MODES MAXCHANNELS NICKLEN MAXBANS TOPICLEN KICKLEN CHANNELLEN CHIDLEN SILENCE AWAYLEN MAXTARGETS WATCH MONITOR] => ->(v) { v.to_i }, %w[STATUSMSG ELIST CHANTYPES] => ->(v) { v.split("") }, %w[CASEMAPPING] => ->(v) { v.to_sym }, %w[NETWORK] => ->(v) { v }, %w[PREFIX] => ->(v) { modes, prefixes = v.match(/^\((.+)\)(.+)$/)[1..2] h = {} modes.split("").each_with_index do |c, i| h[c] = prefixes[i] end h }, %w[CHANMODES] => ->(v) { h = {} h["A"], h["B"], h["C"], h["D"] = v.split(",").map {|l| l.split("")} h }, %w[CHANLIMIT MAXLIST IDCHAN] => ->(v) { h = {} v.split(",").each do |pair| args, num = pair.split(":") args.split("").each do |arg| h[arg] = num.to_i end end h }, %w[TARGMAX] => ->(v) { h = {} v.split(",").each do |pair| name, value = pair.split(":") h[name] = value.to_i end h }, }
Instance Attribute Summary collapse
-
#isupport ⇒ Hash
The isupport options contained in the command.
Attributes inherited from Numeric
Attributes inherited from IRCSupport::Message
Instance Method Summary collapse
-
#initialize(args) ⇒ Numeric005
constructor
A new instance of Numeric005.
Methods inherited from Numeric
Methods inherited from IRCSupport::Message
Constructor Details
#initialize(args) ⇒ Numeric005
Returns a new instance of Numeric005.
101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/ircsupport/message.rb', line 101 def initialize(args) super(args) @isupport = {} args[:args].each do |value| name, value = value.split(/=/, 2) if value proc = @@isupport_mappings.find {|key, _| key.include?(name)} @isupport[name] = (proc && proc[1].call(value)) || value else @isupport[name] = true end end end |
Instance Attribute Details
#isupport ⇒ Hash
Returns The isupport options contained in the command.
98 99 100 |
# File 'lib/ircsupport/message.rb', line 98 def isupport @isupport end |