Class: IRC::Commands::PartCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/irc/commands/part_command.rb

Overview

4.2.2 Part message

Command: PART Parameters: <channel>,<channel>

The PART message causes the client sending the message to be removed from the list of active users for all given channels listed in the parameter string.

Numeric Replies:

ERR_NEEDMOREPARAMS ERR_NOSUCHCHANNEL ERR_NOTONCHANNEL

Examples:

PART #twilight_zone ; leave channel “#twilight_zone”

PART #oz-ops,&group5 ; leave both channels “&group5” and

; "#oz-ops".

Instance Attribute Summary collapse

Attributes inherited from Command

#response

Instance Method Summary collapse

Methods inherited from Command

#execute, #on_server_response, #to_s, #valid_response?, #wait

Methods included from IRC::Client::ConnectionListener

#on_connect, #on_disconnect, #on_error, #on_join, #on_join_failure, #on_kick, #on_nick, #on_nick_already_in_use, #on_notice, #on_part, #on_part_failure, #on_ping, #on_pong, #on_private_message, #on_registration, #on_registration_failure, #on_server_response, #on_welcome

Constructor Details

#initialize(channels) ⇒ PartCommand

Returns a new instance of PartCommand.

Raises:



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/irc/commands/part_command.rb', line 59

def initialize(channels)

  raise InvalidCommand.new("Can't create part command. No channels.") unless channels
  
  if channels.instance_of?(Array)
  
    @channels = channels
  
  else
  
    @channels = Array.new
    @channels << channels
            
  end
  
  super(command)              
  
end

Instance Attribute Details

#channelsObject (readonly)

Returns the value of attribute channels.



57
58
59
# File 'lib/irc/commands/part_command.rb', line 57

def channels
  @channels
end

Instance Method Details

#commandObject



78
79
80
# File 'lib/irc/commands/part_command.rb', line 78

def command 
  return "PART #{channels.join(',')}"
end