Class: IRC::Server::Channels

Inherits:
ThreadSafeHash show all
Defined in:
lib/failirc/server/channels.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ThreadSafeHash

#[], #[]=

Methods inherited from CaseInsensitiveHash

#[], #[]=

Constructor Details

#initialize(server, *args) ⇒ Channels

Returns a new instance of Channels.



31
32
33
34
35
# File 'lib/failirc/server/channels.rb', line 31

def initialize (server, *args)
    @server = server

    super(*args)
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.



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

def server
  @server
end

Instance Method Details

#__deleteObject



37
# File 'lib/failirc/server/channels.rb', line 37

alias __delete delete

#add(channel) ⇒ Object



47
48
49
# File 'lib/failirc/server/channels.rb', line 47

def add (channel)
    self[channel.name] = channel
end

#delete(channel) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/failirc/server/channels.rb', line 39

def delete (channel)
    if channel.is_a?(Channel)
        __delete(channel.name)
    else
        __delete(channel)
    end
end

#to_s(thing = nil) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/failirc/server/channels.rb', line 64

def to_s (thing=nil)
    result = ''


    if thing.is_a?(Client) || thing.is_a?(User)
        each_value {|channel|
            result << " #{channel.user(thing).modes[:level]}#{channel.name}"
        }
    else
        each_value {|channel|
            result << " #{channel.name}"
        }       
    end

    return result[1, result.length]
end

#unique_usersObject

get single users in the channels



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/failirc/server/channels.rb', line 52

def unique_users
    result = Clients.new(server)

    each_value {|channel|
        channel.users.each {|nick, user|
            result[nick] = user.client
        }
    }

    return result
end