Class: MessageFactory::Handlers::Join

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

Instance Method Summary collapse

Instance Method Details

#process(string) ⇒ Object

string

string to process

Create a new Join message OpenStruct will contain: #type #direction #raw #received #source #channel :nodoc: :mod_spox!~mod_spox@host JOIN :#m



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

def process(string)
    string = string.dup
    orig = string.dup
    m = nil
    begin
        m = mk_struct(string)
        m.type = :join
        string.slice!(0)
        m.source = string.slice!(0, string.index(' '))
        string.slice!(0)
        raise 'error' unless string.slice!(0, string.index(' ')).to_sym == :JOIN
        string.slice!(0, string.index(':')+1)
        m.channel = string
    rescue
        raise "Failed to parse Join message: #{orig}"
    end
    m
end

#types_processObject



5
6
7
# File 'lib/messagefactory/handlers/JOIN.rb', line 5

def types_process
    :JOIN
end