Class: Syndi::IRC::Object::User
- Defined in:
- lib/syndi/irc/object/user.rb
Overview
A class which represents an individual user on IRC, and which provides useful data regarding said user, and methods using which to interact with the user.
Instance Attribute Summary collapse
-
#account ⇒ String
If the user is logged in, their account name.
- #away ⇒ true, false
- #host ⇒ String?
-
#irc ⇒ Syndi::IRC::Server
The server on which the user is located.
-
#nick ⇒ String
The user's nickname.
- #user ⇒ String?
Attributes inherited from Entity
Instance Method Summary collapse
-
#host_known? ⇒ true, false
This will check whether the user's hostname is known.
-
#initialize(irc, nickname, username = nil, hostname = nil, away = false) ⇒ User
constructor
Process a new user.
- #inspect ⇒ Object
-
#logged_in? ⇒ true, false
This will check whether the user is logged in.
-
#login(accountname) ⇒ Object
If the user logs into an account, this is used to specify the name of the account with which ze has identified.
-
#logout ⇒ Object
If the user logs out of hir account, this is used to update their logged-in status.
-
#user_known? ⇒ true, false
This will check whether the user's username is known.
Methods inherited from Entity
#channel?, #msg, #to_s, #user?
Constructor Details
#initialize(irc, nickname, username = nil, hostname = nil, away = false) ⇒ User
Process a new user.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/syndi/irc/object/user.rb', line 57 def initialize(irc, nickname, username=nil, hostname=nil, away=false) super(irc, :user, nickname) # Entity#initialize @nick = nickname @user = username @host = hostname @away = away @account = nil end |
Instance Attribute Details
#account ⇒ String
Returns If the user is logged in, their account name.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/syndi/irc/object/user.rb', line 43 class User < Entity attr_reader :nick, :user, :host, :account, :away # Process a new user. # # @param [Syndi::IRC::Server] irc The server the user is on. # @param [String] nickname The user's nickname. # @param [String] username The user's username or ident. # @param [String] hostname The user's hostname or mask. # @param [true, false] away Whether the user is away: +true+ or +false+. # # @example # user = Syndi::IRC::Object::User.new(irc, 'missfoo', 'cowmilk', 'the.night.is.lovely', false) def initialize(irc, nickname, username=nil, hostname=nil, away=false) super(irc, :user, nickname) # Entity#initialize @nick = nickname @user = username @host = hostname @away = away @account = nil end # If the user logs into an account, this is used to specify the name of # the account with which ze has identified. # # @param [String] accountname The name of the account. # # @example # user.login('root') def login(accountname) unless accountname.nil? @account = accountname end end # If the user logs out of hir account, this is used to update their # logged-in status. def logout @account = nil end # Update the user's known away status. # # @param [true, false] new The user's new away status, which should be +true+ or +false+. def away=(new) if new == true or new == false @away = new end end # Update the user's known hostname or mask. # # @param [String] new The user's new hostname. def host=(new); @host = new unless new.nil?; end # Update the user's known nickname. # # @param [String] new The user's new nickname. def nick=(new); @nick = new unless new.nil?; end # Update the user's known username or ident. # # @param [String] new The user's new username. def user=(new); @user = new unless new.nil?; end # This will check whether the user's username is known. # # @return [true] If known. # @return [false] If Unknown. def user_known?; @user.nil? ? false : true; end # This will check whether the user's hostname is known. # # @return [true] If known. # @return [false] If Unknown. def host_known?; @host.nil? ? false : true; end # This will check whether the user is logged in. # # @return [true] If known. # @return [false] If Unknown. def logged_in?; @account.nil? ? false : true; end def inspect; "#<Syndi::IRC::Object::User: irc=#@irc nick=#@nick account=#@account>"; end end |
#away ⇒ true, false
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/syndi/irc/object/user.rb', line 43 class User < Entity attr_reader :nick, :user, :host, :account, :away # Process a new user. # # @param [Syndi::IRC::Server] irc The server the user is on. # @param [String] nickname The user's nickname. # @param [String] username The user's username or ident. # @param [String] hostname The user's hostname or mask. # @param [true, false] away Whether the user is away: +true+ or +false+. # # @example # user = Syndi::IRC::Object::User.new(irc, 'missfoo', 'cowmilk', 'the.night.is.lovely', false) def initialize(irc, nickname, username=nil, hostname=nil, away=false) super(irc, :user, nickname) # Entity#initialize @nick = nickname @user = username @host = hostname @away = away @account = nil end # If the user logs into an account, this is used to specify the name of # the account with which ze has identified. # # @param [String] accountname The name of the account. # # @example # user.login('root') def login(accountname) unless accountname.nil? @account = accountname end end # If the user logs out of hir account, this is used to update their # logged-in status. def logout @account = nil end # Update the user's known away status. # # @param [true, false] new The user's new away status, which should be +true+ or +false+. def away=(new) if new == true or new == false @away = new end end # Update the user's known hostname or mask. # # @param [String] new The user's new hostname. def host=(new); @host = new unless new.nil?; end # Update the user's known nickname. # # @param [String] new The user's new nickname. def nick=(new); @nick = new unless new.nil?; end # Update the user's known username or ident. # # @param [String] new The user's new username. def user=(new); @user = new unless new.nil?; end # This will check whether the user's username is known. # # @return [true] If known. # @return [false] If Unknown. def user_known?; @user.nil? ? false : true; end # This will check whether the user's hostname is known. # # @return [true] If known. # @return [false] If Unknown. def host_known?; @host.nil? ? false : true; end # This will check whether the user is logged in. # # @return [true] If known. # @return [false] If Unknown. def logged_in?; @account.nil? ? false : true; end def inspect; "#<Syndi::IRC::Object::User: irc=#@irc nick=#@nick account=#@account>"; end end |
#host ⇒ String?
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/syndi/irc/object/user.rb', line 43 class User < Entity attr_reader :nick, :user, :host, :account, :away # Process a new user. # # @param [Syndi::IRC::Server] irc The server the user is on. # @param [String] nickname The user's nickname. # @param [String] username The user's username or ident. # @param [String] hostname The user's hostname or mask. # @param [true, false] away Whether the user is away: +true+ or +false+. # # @example # user = Syndi::IRC::Object::User.new(irc, 'missfoo', 'cowmilk', 'the.night.is.lovely', false) def initialize(irc, nickname, username=nil, hostname=nil, away=false) super(irc, :user, nickname) # Entity#initialize @nick = nickname @user = username @host = hostname @away = away @account = nil end # If the user logs into an account, this is used to specify the name of # the account with which ze has identified. # # @param [String] accountname The name of the account. # # @example # user.login('root') def login(accountname) unless accountname.nil? @account = accountname end end # If the user logs out of hir account, this is used to update their # logged-in status. def logout @account = nil end # Update the user's known away status. # # @param [true, false] new The user's new away status, which should be +true+ or +false+. def away=(new) if new == true or new == false @away = new end end # Update the user's known hostname or mask. # # @param [String] new The user's new hostname. def host=(new); @host = new unless new.nil?; end # Update the user's known nickname. # # @param [String] new The user's new nickname. def nick=(new); @nick = new unless new.nil?; end # Update the user's known username or ident. # # @param [String] new The user's new username. def user=(new); @user = new unless new.nil?; end # This will check whether the user's username is known. # # @return [true] If known. # @return [false] If Unknown. def user_known?; @user.nil? ? false : true; end # This will check whether the user's hostname is known. # # @return [true] If known. # @return [false] If Unknown. def host_known?; @host.nil? ? false : true; end # This will check whether the user is logged in. # # @return [true] If known. # @return [false] If Unknown. def logged_in?; @account.nil? ? false : true; end def inspect; "#<Syndi::IRC::Object::User: irc=#@irc nick=#@nick account=#@account>"; end end |
#irc ⇒ Syndi::IRC::Server
Returns The server on which the user is located.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/syndi/irc/object/user.rb', line 43 class User < Entity attr_reader :nick, :user, :host, :account, :away # Process a new user. # # @param [Syndi::IRC::Server] irc The server the user is on. # @param [String] nickname The user's nickname. # @param [String] username The user's username or ident. # @param [String] hostname The user's hostname or mask. # @param [true, false] away Whether the user is away: +true+ or +false+. # # @example # user = Syndi::IRC::Object::User.new(irc, 'missfoo', 'cowmilk', 'the.night.is.lovely', false) def initialize(irc, nickname, username=nil, hostname=nil, away=false) super(irc, :user, nickname) # Entity#initialize @nick = nickname @user = username @host = hostname @away = away @account = nil end # If the user logs into an account, this is used to specify the name of # the account with which ze has identified. # # @param [String] accountname The name of the account. # # @example # user.login('root') def login(accountname) unless accountname.nil? @account = accountname end end # If the user logs out of hir account, this is used to update their # logged-in status. def logout @account = nil end # Update the user's known away status. # # @param [true, false] new The user's new away status, which should be +true+ or +false+. def away=(new) if new == true or new == false @away = new end end # Update the user's known hostname or mask. # # @param [String] new The user's new hostname. def host=(new); @host = new unless new.nil?; end # Update the user's known nickname. # # @param [String] new The user's new nickname. def nick=(new); @nick = new unless new.nil?; end # Update the user's known username or ident. # # @param [String] new The user's new username. def user=(new); @user = new unless new.nil?; end # This will check whether the user's username is known. # # @return [true] If known. # @return [false] If Unknown. def user_known?; @user.nil? ? false : true; end # This will check whether the user's hostname is known. # # @return [true] If known. # @return [false] If Unknown. def host_known?; @host.nil? ? false : true; end # This will check whether the user is logged in. # # @return [true] If known. # @return [false] If Unknown. def logged_in?; @account.nil? ? false : true; end def inspect; "#<Syndi::IRC::Object::User: irc=#@irc nick=#@nick account=#@account>"; end end |
#nick ⇒ String
Returns The user's nickname.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/syndi/irc/object/user.rb', line 43 class User < Entity attr_reader :nick, :user, :host, :account, :away # Process a new user. # # @param [Syndi::IRC::Server] irc The server the user is on. # @param [String] nickname The user's nickname. # @param [String] username The user's username or ident. # @param [String] hostname The user's hostname or mask. # @param [true, false] away Whether the user is away: +true+ or +false+. # # @example # user = Syndi::IRC::Object::User.new(irc, 'missfoo', 'cowmilk', 'the.night.is.lovely', false) def initialize(irc, nickname, username=nil, hostname=nil, away=false) super(irc, :user, nickname) # Entity#initialize @nick = nickname @user = username @host = hostname @away = away @account = nil end # If the user logs into an account, this is used to specify the name of # the account with which ze has identified. # # @param [String] accountname The name of the account. # # @example # user.login('root') def login(accountname) unless accountname.nil? @account = accountname end end # If the user logs out of hir account, this is used to update their # logged-in status. def logout @account = nil end # Update the user's known away status. # # @param [true, false] new The user's new away status, which should be +true+ or +false+. def away=(new) if new == true or new == false @away = new end end # Update the user's known hostname or mask. # # @param [String] new The user's new hostname. def host=(new); @host = new unless new.nil?; end # Update the user's known nickname. # # @param [String] new The user's new nickname. def nick=(new); @nick = new unless new.nil?; end # Update the user's known username or ident. # # @param [String] new The user's new username. def user=(new); @user = new unless new.nil?; end # This will check whether the user's username is known. # # @return [true] If known. # @return [false] If Unknown. def user_known?; @user.nil? ? false : true; end # This will check whether the user's hostname is known. # # @return [true] If known. # @return [false] If Unknown. def host_known?; @host.nil? ? false : true; end # This will check whether the user is logged in. # # @return [true] If known. # @return [false] If Unknown. def logged_in?; @account.nil? ? false : true; end def inspect; "#<Syndi::IRC::Object::User: irc=#@irc nick=#@nick account=#@account>"; end end |
#user ⇒ String?
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/syndi/irc/object/user.rb', line 43 class User < Entity attr_reader :nick, :user, :host, :account, :away # Process a new user. # # @param [Syndi::IRC::Server] irc The server the user is on. # @param [String] nickname The user's nickname. # @param [String] username The user's username or ident. # @param [String] hostname The user's hostname or mask. # @param [true, false] away Whether the user is away: +true+ or +false+. # # @example # user = Syndi::IRC::Object::User.new(irc, 'missfoo', 'cowmilk', 'the.night.is.lovely', false) def initialize(irc, nickname, username=nil, hostname=nil, away=false) super(irc, :user, nickname) # Entity#initialize @nick = nickname @user = username @host = hostname @away = away @account = nil end # If the user logs into an account, this is used to specify the name of # the account with which ze has identified. # # @param [String] accountname The name of the account. # # @example # user.login('root') def login(accountname) unless accountname.nil? @account = accountname end end # If the user logs out of hir account, this is used to update their # logged-in status. def logout @account = nil end # Update the user's known away status. # # @param [true, false] new The user's new away status, which should be +true+ or +false+. def away=(new) if new == true or new == false @away = new end end # Update the user's known hostname or mask. # # @param [String] new The user's new hostname. def host=(new); @host = new unless new.nil?; end # Update the user's known nickname. # # @param [String] new The user's new nickname. def nick=(new); @nick = new unless new.nil?; end # Update the user's known username or ident. # # @param [String] new The user's new username. def user=(new); @user = new unless new.nil?; end # This will check whether the user's username is known. # # @return [true] If known. # @return [false] If Unknown. def user_known?; @user.nil? ? false : true; end # This will check whether the user's hostname is known. # # @return [true] If known. # @return [false] If Unknown. def host_known?; @host.nil? ? false : true; end # This will check whether the user is logged in. # # @return [true] If known. # @return [false] If Unknown. def logged_in?; @account.nil? ? false : true; end def inspect; "#<Syndi::IRC::Object::User: irc=#@irc nick=#@nick account=#@account>"; end end |
Instance Method Details
#host_known? ⇒ true, false
This will check whether the user's hostname is known.
121 |
# File 'lib/syndi/irc/object/user.rb', line 121 def host_known?; @host.nil? ? false : true; end |
#inspect ⇒ Object
129 |
# File 'lib/syndi/irc/object/user.rb', line 129 def inspect; "#<Syndi::IRC::Object::User: irc=#@irc nick=#@nick account=#@account>"; end |
#logged_in? ⇒ true, false
This will check whether the user is logged in.
127 |
# File 'lib/syndi/irc/object/user.rb', line 127 def logged_in?; @account.nil? ? false : true; end |
#login(accountname) ⇒ Object
If the user logs into an account, this is used to specify the name of the account with which ze has identified.
75 76 77 78 79 |
# File 'lib/syndi/irc/object/user.rb', line 75 def login(accountname) unless accountname.nil? @account = accountname end end |
#logout ⇒ Object
If the user logs out of hir account, this is used to update their logged-in status.
83 84 85 |
# File 'lib/syndi/irc/object/user.rb', line 83 def logout @account = nil end |
#user_known? ⇒ true, false
This will check whether the user's username is known.
115 |
# File 'lib/syndi/irc/object/user.rb', line 115 def user_known?; @user.nil? ? false : true; end |