Class: IRCd::User
- Inherits:
-
Object
- Object
- IRCd::User
- Defined in:
- lib/rupircd/user.rb
Constant Summary collapse
- @@identifier =
0
Instance Attribute Summary collapse
-
#away ⇒ Object
Returns the value of attribute away.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#invisible ⇒ Object
Returns the value of attribute invisible.
-
#joined_channels ⇒ Object
Returns the value of attribute joined_channels.
-
#local_operator ⇒ Object
Returns the value of attribute local_operator.
-
#nick ⇒ Object
Returns the value of attribute nick.
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#real ⇒ Object
Returns the value of attribute real.
-
#restriction ⇒ Object
Returns the value of attribute restriction.
-
#s ⇒ Object
Returns the value of attribute s.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#wallop ⇒ Object
Returns the value of attribute wallop.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #away? ⇒ Boolean
- #get_mode_flags ⇒ Object
-
#initialize(nick, user, host, real, socket, mode = 0) ⇒ User
constructor
A new instance of User.
- #set_flags(*flags) ⇒ Object
- #to_a ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(nick, user, host, real, socket, mode = 0) ⇒ User
Returns a new instance of User.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rupircd/user.rb', line 24 def initialize(nick, user, host, real, socket, mode=0) @nick = nick @user = user @host = host @real = real @identifier = (@@identifier += 1) @away = "" @invisible = false @wallop = false @restriction = false @operator = false @local_operator = false @s = false @socket = socket @joined_channels = [] end |
Instance Attribute Details
#away ⇒ Object
Returns the value of attribute away.
17 18 19 |
# File 'lib/rupircd/user.rb', line 17 def away @away end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
16 17 18 |
# File 'lib/rupircd/user.rb', line 16 def host @host end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
16 17 18 |
# File 'lib/rupircd/user.rb', line 16 def identifier @identifier end |
#invisible ⇒ Object
Returns the value of attribute invisible.
17 18 19 |
# File 'lib/rupircd/user.rb', line 17 def invisible @invisible end |
#joined_channels ⇒ Object
Returns the value of attribute joined_channels.
17 18 19 |
# File 'lib/rupircd/user.rb', line 17 def joined_channels @joined_channels end |
#local_operator ⇒ Object
Returns the value of attribute local_operator.
17 18 19 |
# File 'lib/rupircd/user.rb', line 17 def local_operator @local_operator end |
#nick ⇒ Object
Returns the value of attribute nick.
17 18 19 |
# File 'lib/rupircd/user.rb', line 17 def nick @nick end |
#operator ⇒ Object
Returns the value of attribute operator.
17 18 19 |
# File 'lib/rupircd/user.rb', line 17 def operator @operator end |
#real ⇒ Object
Returns the value of attribute real.
17 18 19 |
# File 'lib/rupircd/user.rb', line 17 def real @real end |
#restriction ⇒ Object
Returns the value of attribute restriction.
17 18 19 |
# File 'lib/rupircd/user.rb', line 17 def restriction @restriction end |
#s ⇒ Object
Returns the value of attribute s.
17 18 19 |
# File 'lib/rupircd/user.rb', line 17 def s @s end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
16 17 18 |
# File 'lib/rupircd/user.rb', line 16 def socket @socket end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
16 17 18 |
# File 'lib/rupircd/user.rb', line 16 def user @user end |
#wallop ⇒ Object
Returns the value of attribute wallop.
17 18 19 |
# File 'lib/rupircd/user.rb', line 17 def wallop @wallop end |
Instance Method Details
#==(other) ⇒ Object
98 99 100 |
# File 'lib/rupircd/user.rb', line 98 def ==(other) @identifier == other.identifier end |
#away? ⇒ Boolean
41 42 43 |
# File 'lib/rupircd/user.rb', line 41 def away? !@away.empty? end |
#get_mode_flags ⇒ Object
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rupircd/user.rb', line 87 def get_mode_flags mode = "" mode << "i" if @invisible mode << "w" if @wallop mode << "r" if @restriction mode << "o" if @operator mode << "O" if @local_operator mode << "s" if @s mode end |
#set_flags(*flags) ⇒ Object
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 |
# File 'lib/rupircd/user.rb', line 49 def set_flags(*flags) rls = [] flags.each{|flg| fl = flg[0,1] toggle = flg[0] == ?+ flg[1..-1].split("").each{|md| case md when "i" @invisible = toggle fl << "i" when "w" @wallop = toggle fl << "w" when"r" if toggle @restriction = true fl << "r" end when "o" unless toggle @operator = false fl << "o" end when "O" unless toggle @local_operator = false fl << "O" end when "s" @s = toggle fl << "s" end } rls << fl } rls end |
#to_a ⇒ Object
45 46 47 |
# File 'lib/rupircd/user.rb', line 45 def to_a [@nick, @user, @host, "*", @real] end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/rupircd/user.rb', line 20 def to_s @nick + "!" + @user + "@" + @host end |