Class: IRC::Client::Module

Inherits:
Object show all
Defined in:
lib/failirc/client/module.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Module

Returns a new instance of Module.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/failirc/client/module.rb', line 29

def initialize (client)
    @client = client

    if @aliases
        if @aliases[:input]
            @aliases[:input].each {|key, value|
                @client.dispatcher.alias(:input, key, value)
            }
        end

        if @aliases[:output]
            @aliases[:output].each {|key, value|
                @client.dispatcher.alias(:output, key, value)
            }
        end
    end

    if @events
        if @events[:pre]
            @client.dispatcher.register(:pre, nil, @events[:pre])
        end

        if @events[:post]
            @client.dispatcher.register(:post, nil, @events[:post])
        end

        if @events[:default]
            @client.dispatcher.register(:default, nil, @events[:default])
        end
        
        if @events[:custom]
            @events[:custom].each {|key, value|
                @client.dispatcher.register(:custom, key, value)
            }
        end

        if @events[:input]
            @events[:input].each {|key, value|
                @client.dispatcher.register(:input, key, value)
            }
        end

        if @events[:output]
            @events[:output].each {|key, value|
                @client.dispatcher.register(:output, key, value)
            }
        end
    end

    begin
        rehash
    rescue NameError
    rescue Exception => e
        self.debug e
    end
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



27
28
29
# File 'lib/failirc/client/module.rb', line 27

def client
  @client
end

Instance Method Details

#finalizeObject



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/failirc/client/module.rb', line 86

def finalize
    if @aliases
        @aliases.each_key {|key|
            @client.dispatcher.alias(key, nil)
        }
    end

    if @events
        @events.each_key {|key|
            @client.dispatcher.register(key, nil)
        }
    end
end