Class: IRC::Client::Channels

Inherits:
ThreadSafeHash show all
Defined in:
lib/failirc/client/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.



32
33
34
35
36
# File 'lib/failirc/client/channels.rb', line 32

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

    super(*args)
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.



30
31
32
# File 'lib/failirc/client/channels.rb', line 30

def server
  @server
end

Instance Method Details

#__deleteObject



38
# File 'lib/failirc/client/channels.rb', line 38

alias __delete delete

#add(channel) ⇒ Object



48
49
50
# File 'lib/failirc/client/channels.rb', line 48

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

#delete(channel) ⇒ Object



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

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

#to_s(thing = nil) ⇒ Object



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

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



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

def unique_users
    result = {}

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

    return result
end