Class: Syndi::IRC::Object::User

Inherits:
Entity
  • Object
show all
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.

Author:

  • noxgirl

Since:

  • 4.0.0

Instance Attribute Summary collapse

Attributes inherited from Entity

#name

Instance Method Summary collapse

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.

Examples:

user = Syndi::IRC::Object::User.new(irc, 'missfoo', 'cowmilk', 'the.night.is.lovely', false)

Parameters:

  • irc (Syndi::IRC::Server)

    The server the user is on.

  • nickname (String)

    The user's nickname.

  • username (String) (defaults to: nil)

    The user's username or ident.

  • hostname (String) (defaults to: nil)

    The user's hostname or mask.

  • away (true, false) (defaults to: false)

    Whether the user is away: +true+ or +false+.

Since:

  • 4.0.0



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

#accountString

Returns If the user is logged in, their account name.

Returns:

  • (String)

    If the user is logged in, their account name.

See Also:

Since:

  • 4.0.0



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 (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

#awaytrue, false

Returns:

  • (true)

    If the user is away.

  • (false)

    If the user is present.

Since:

  • 4.0.0



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 (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

#hostString?

Returns:

  • (String)

    If known, the user's hostname or mask.

  • (nil)

    If unknown.

See Also:

Since:

  • 4.0.0



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 (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

#ircSyndi::IRC::Server

Returns The server on which the user is located.

Returns:



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 (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

#nickString

Returns The user's nickname.

Returns:

  • (String)

    The user's nickname.

Since:

  • 4.0.0



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 (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

#userString?

Returns:

  • (String)

    If known, the user's username or ident.

  • (nil)

    If unknown.

See Also:

Since:

  • 4.0.0



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 (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.

Returns:

  • (true)

    If known.

  • (false)

    If Unknown.

Since:

  • 4.0.0



121
# File 'lib/syndi/irc/object/user.rb', line 121

def host_known?; @host.nil? ? false : true; end

#inspectObject

Since:

  • 4.0.0



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.

Returns:

  • (true)

    If known.

  • (false)

    If Unknown.

Since:

  • 4.0.0



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.

Examples:

user.('root')

Parameters:

  • accountname (String)

    The name of the account.

Since:

  • 4.0.0



75
76
77
78
79
# File 'lib/syndi/irc/object/user.rb', line 75

def (accountname)
  unless accountname.nil?
    @account = accountname
  end
end

#logoutObject

If the user logs out of hir account, this is used to update their logged-in status.

Since:

  • 4.0.0



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.

Returns:

  • (true)

    If known.

  • (false)

    If Unknown.

Since:

  • 4.0.0



115
# File 'lib/syndi/irc/object/user.rb', line 115

def user_known?; @user.nil? ? false : true; end