Class: IRCSupport::Message::Numeric005

Inherits:
Numeric show all
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

Attributes inherited from Numeric

#name

Attributes inherited from IRCSupport::Message

#args, #command, #prefix

Instance Method Summary collapse

Methods inherited from Numeric

#is_error?

Methods inherited from IRCSupport::Message

#type

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

#isupportHash

Returns The isupport options contained in the command.

Returns:

  • (Hash)

    The isupport options contained in the command.



98
99
100
# File 'lib/ircsupport/message.rb', line 98

def isupport
  @isupport
end