Class: MessageFactory::Handlers::BadNick

Inherits:
Handler
  • Object
show all
Defined in:
lib/messagefactory/handlers/432.rb

Instance Method Summary collapse

Instance Method Details

#process(string) ⇒ Object

string

string to process

Create a new BadNick message OpenStruct will contain: #type #direction #raw #bad_nick #received :nodoc: ‘:the.server 432 spox 999 :Erroneous Nickname’



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/messagefactory/handlers/432.rb', line 14

def process(string)
    m = nil
    string = string.dup
    orig = string.dup
    begin
        m = mk_struct(string)
        m.type = :badnick
        string.slice!(0)
        m.server = string.slice!(0, string.index(' '))
        string.slice!(0)
        raise unless string.slice!(0, string.index(' ')).to_sym == :'432'
        2.times{string.slice!(0, string.index(' ')+1)}
        m.bad_nick = string.slice!(0, string.index(' '))
    rescue
        raise "Failed to parse BadNick string: #{orig}"
    end
    m
end

#types_processObject

Returns type(s) supported



6
7
8
# File 'lib/messagefactory/handlers/432.rb', line 6

def types_process
    :'432'
end