Class: IRCSupport::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/ircsupport/message.rb

Defined Under Namespace

Classes: CAP, CTCP, CTCPReply, ChannelModeChange, DCC, Error, Invite, Join, Kick, Message, Nick, Numeric, Numeric005, Numeric352, Numeric353, Part, Ping, Quit, ServerNotice, Topic, UserModeChange

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Message

Returns a new instance of Message.



17
18
19
20
21
# File 'lib/ircsupport/message.rb', line 17

def initialize(args)
  @prefix = args[:prefix]
  @command = args[:command]
  @args = args[:args]
end

Instance Attribute Details

#argsArray

Returns The arguments to the IRC command.

Returns:

  • (Array)

    The arguments to the IRC command.



14
15
16
# File 'lib/ircsupport/message.rb', line 14

def args
  @args
end

#commandString

Returns The IRC command.

Returns:

  • (String)

    The IRC command.



11
12
13
# File 'lib/ircsupport/message.rb', line 11

def command
  @command
end

#prefixString

Returns The sender prefix of the IRC message, if any.

Returns:

  • (String)

    The sender prefix of the IRC message, if any.



8
9
10
# File 'lib/ircsupport/message.rb', line 8

def prefix
  @prefix
end

Instance Method Details

#typeString

Returns The type of the IRC message.

Returns:

  • (String)

    The type of the IRC message.



24
25
26
27
28
29
# File 'lib/ircsupport/message.rb', line 24

def type
  return @type if @type
  return @command.downcase.to_sym if self.class.name == 'IRCSupport::Message'
  type = self.class.name.match(/^IRCSupport::Message::(.*)/)[1]
  return type.gsub(/::|(?<=[[:lower:]])(?=[[:upper:]])/, '_').downcase.to_sym
end