Class: IRC::Client::Server

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, socket, config, name = nil) ⇒ Server

Returns a new instance of Server.



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
# File 'lib/failirc/client/server.rb', line 31

def initialize (client, socket, config, name=nil)
    @client = client
    @socket = socket
    @config = config

    @channels = Channels.new(self)
    @clients  = Clients.new(self)

    @host = socket.peeraddr[2]
    @ip   = socket.peeraddr[3]
    @port = socket.peeraddr[1]

    nick = client.nick

    if !name
        name = @host
    else
        if client.server name
            raise Error.new "There is already a server named `#{name}`."
        end
    end

    while client.server name
        name << '_'
    end

    @name = name
end

Instance Attribute Details

#channelsObject (readonly)

Returns the value of attribute channels.



28
29
30
# File 'lib/failirc/client/server.rb', line 28

def channels
  @channels
end

#clientObject (readonly)

Returns the value of attribute client.



28
29
30
# File 'lib/failirc/client/server.rb', line 28

def client
  @client
end

#clientsObject (readonly)

Returns the value of attribute clients.



28
29
30
# File 'lib/failirc/client/server.rb', line 28

def clients
  @clients
end

#configObject (readonly)

Returns the value of attribute config.



28
29
30
# File 'lib/failirc/client/server.rb', line 28

def config
  @config
end

#hostObject (readonly)

Returns the value of attribute host.



28
29
30
# File 'lib/failirc/client/server.rb', line 28

def host
  @host
end

#ipObject (readonly)

Returns the value of attribute ip.



28
29
30
# File 'lib/failirc/client/server.rb', line 28

def ip
  @ip
end

#nameObject

Returns the value of attribute name.



28
29
30
# File 'lib/failirc/client/server.rb', line 28

def name
  @name
end

#nickObject

Returns the value of attribute nick.



29
30
31
# File 'lib/failirc/client/server.rb', line 29

def nick
  @nick
end

#passwordObject

Returns the value of attribute password.



29
30
31
# File 'lib/failirc/client/server.rb', line 29

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



28
29
30
# File 'lib/failirc/client/server.rb', line 28

def port
  @port
end

#socketObject (readonly)

Returns the value of attribute socket.



28
29
30
# File 'lib/failirc/client/server.rb', line 28

def socket
  @socket
end

Instance Method Details

#raw(text) ⇒ Object



77
78
79
80
# File 'lib/failirc/client/server.rb', line 77

def raw (text)
    @client.dispatcher.dispatch :output, self, text
    @client.dispatcher.connection.output.push @socket, text
end

#send(symbol, *args) ⇒ Object



69
70
71
72
73
74
75
# File 'lib/failirc/client/server.rb', line 69

def send (symbol, *args)
    begin
        self.method(symbol).call(*args)
    rescue Exception => e
        self.debug e
    end
end

#to_sObject



82
83
84
# File 'lib/failirc/client/server.rb', line 82

def to_s
    name
end