Class: IRC::Client::Dispatcher::ConnectionDispatcher::Connections

Inherits:
Object
  • Object
show all
Defined in:
lib/failirc/client/dispatcher/connectiondispatcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Connections

Returns a new instance of Connections.



39
40
41
42
43
44
45
46
47
48
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 39

def initialize (client)
    @client = client
    
    @data           = ThreadSafeHash.new
    @data[:sockets] = []
    @data[:servers] = {
        :bySocket => {},
        :byName   => {},
    }
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



37
38
39
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 37

def client
  @client
end

Instance Method Details

#delete(socket) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 66

def delete (socket)
    if !exists?(socket)
        return
    end

    @data[:sockets].delete(socket)

    server = @data[:servers][:bySocket][socket]
    @data[:servers][:bySocket].delete(socket)
    @data[:servers][:byName].delete(server.name)
end

#empty?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 58

def empty?
    sockets.empty?
end

#exists?(socket) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 62

def exists? (socket)
    servers[:bySocket][socket] ? true : false
end

#serversObject



54
55
56
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 54

def servers
    @data[:servers]
end

#socketsObject



50
51
52
# File 'lib/failirc/client/dispatcher/connectiondispatcher.rb', line 50

def sockets
    @data[:sockets]
end