Class: IRC::Client::Users
- Inherits:
-
ThreadSafeHash
- Object
- Hash
- CaseInsensitiveHash
- ThreadSafeHash
- IRC::Client::Users
- Defined in:
- lib/failirc/client/users.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
Instance Method Summary collapse
- #[](user) ⇒ Object
- #[]=(user, value) ⇒ Object
- #__delete ⇒ Object
- #__get ⇒ Object
- #__set ⇒ Object
- #add(user) ⇒ Object
- #client ⇒ Object
- #delete(key) ⇒ Object
-
#initialize(channel, *args) ⇒ Users
constructor
A new instance of Users.
- #server ⇒ Object
Constructor Details
#initialize(channel, *args) ⇒ Users
Returns a new instance of Users.
31 32 33 34 35 |
# File 'lib/failirc/client/users.rb', line 31 def initialize (channel, *args) @channel = channel super(*args) end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
29 30 31 |
# File 'lib/failirc/client/users.rb', line 29 def channel @channel end |
Instance Method Details
#[](user) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/failirc/client/users.rb', line 47 def [] (user) if user.is_a?(Client) || user.is_a?(User) user = user.nick end __get(user) end |
#[]=(user, value) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/failirc/client/users.rb', line 57 def []= (user, value) if user.is_a?(Client) || user.is_a?(User) user = user.nick end __set(user, value) end |
#__delete ⇒ Object
65 |
# File 'lib/failirc/client/users.rb', line 65 alias __delete delete |
#__get ⇒ Object
45 |
# File 'lib/failirc/client/users.rb', line 45 alias __get [] |
#__set ⇒ Object
55 |
# File 'lib/failirc/client/users.rb', line 55 alias __set []= |
#add(user) ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/failirc/client/users.rb', line 87 def add (user) if user.is_a?(Client) self[user.nick] = User.new(user, @channel) elsif user.is_a?(User) self[user.nick] = user else raise 'You can only add Client or User.' end end |
#client ⇒ Object
37 38 39 |
# File 'lib/failirc/client/users.rb', line 37 def client @channel.client end |
#delete(key) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/failirc/client/users.rb', line 67 def delete (key) if key.is_a?(User) || key.is_a?(Client) key = key.nick end key = key.downcase user = self[key] if user __delete(key) if channel.empty? server.channels.delete(channel) end end return user end |
#server ⇒ Object
41 42 43 |
# File 'lib/failirc/client/users.rb', line 41 def server @channel.server end |