class Syndi::IRC::Object::User
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.
@api IRC
@since 4.0.0 @author noxgirl
@!attribute irc
@return [Syndi::IRC::Server] The server on which the user is located.
@!attribute nick
@return [String] The user's nickname.
@!attribute user
@return [String] If known, the user's username or ident. @return [nil] If unknown. @see #user_known?
@!attribute host
@return [String] If known, the user's hostname or mask. @return [nil] If unknown. @see #host_known?
@!attribute account
@return [String] If the user is logged in, their account name. @see #logged_in?
@!attribute away
@return [true] If the user is away. @return [false] If the user is present.
Attributes
Public Class Methods
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)
Syndi::IRC::Object::Entity::new
# 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
Public Instance Methods
Update the user's known away status.
@param [true, false] new The user's new away status, which should be true
or false
.
# File lib/syndi/irc/object/user.rb, line 90 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.
# File lib/syndi/irc/object/user.rb, line 99 def host=(new); @host = new unless new.nil?; end
This will check whether the user's hostname is known.
@return [true] If known. @return [false] If Unknown.
# File lib/syndi/irc/object/user.rb, line 121 def host_known?; @host.nil? ? false : true; end
# File lib/syndi/irc/object/user.rb, line 129 def inspect; "#<Syndi::IRC::Object::User: irc=#@irc nick=#@nick account=#@account>"; end
This will check whether the user is logged in.
@return [true] If known. @return [false] If Unknown.
# File lib/syndi/irc/object/user.rb, line 127 def logged_in?; @account.nil? ? false : true; 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')
# File lib/syndi/irc/object/user.rb, line 75 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.
# File lib/syndi/irc/object/user.rb, line 83 def logout @account = nil end
Update the user's known nickname.
@param [String] new The user's new nickname.
# File lib/syndi/irc/object/user.rb, line 104 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.
# File lib/syndi/irc/object/user.rb, line 109 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.
# File lib/syndi/irc/object/user.rb, line 115 def user_known?; @user.nil? ? false : true; end