Class: Relayer::IRC::User
- Inherits:
-
Object
- Object
- Relayer::IRC::User
- Defined in:
- lib/relayer/irc/user.rb
Constant Summary collapse
- IRC_HOSTMASK_REGEX =
/^([^\!@]+)(\!([^\!@]+))(@(.+))$/
Instance Attribute Summary collapse
-
#hostmask ⇒ Object
Returns the value of attribute hostmask.
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#ident ⇒ Object
Returns the value of attribute ident.
-
#nick ⇒ Object
Returns the value of attribute nick.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hostmask) ⇒ User
constructor
A new instance of User.
- #parse_hostmask! ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(hostmask) ⇒ User
Returns a new instance of User.
31 32 33 34 |
# File 'lib/relayer/irc/user.rb', line 31 def initialize(hostmask) @hostmask = hostmask parse_hostmask! end |
Instance Attribute Details
#hostmask ⇒ Object
Returns the value of attribute hostmask.
5 6 7 |
# File 'lib/relayer/irc/user.rb', line 5 def hostmask @hostmask end |
#hostname ⇒ Object
Returns the value of attribute hostname.
5 6 7 |
# File 'lib/relayer/irc/user.rb', line 5 def hostname @hostname end |
#ident ⇒ Object
Returns the value of attribute ident.
5 6 7 |
# File 'lib/relayer/irc/user.rb', line 5 def ident @ident end |
#nick ⇒ Object
Returns the value of attribute nick.
5 6 7 |
# File 'lib/relayer/irc/user.rb', line 5 def nick @nick end |
Class Method Details
.is_user?(hostmask) ⇒ Boolean
7 8 9 |
# File 'lib/relayer/irc/user.rb', line 7 def self.is_user?(hostmask) not IRC_HOSTMASK_REGEX.match(hostmask).nil? end |
.parse_hostmask(hostmask) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/relayer/irc/user.rb', line 15 def self.parse_hostmask(hostmask) match = IRC_HOSTMASK_REGEX.match hostmask return if match.nil? raw, nick, ident_tmp, ident, hostname_tmp, hostname = match.to_a return :nick => nick, :ident => ident, :hostname => hostname end |
Instance Method Details
#parse_hostmask! ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/relayer/irc/user.rb', line 23 def parse_hostmask! parts = User.parse_hostmask @hostmask @nick = parts[:nick] @ident = parts[:ident] @hostname = parts[:hostname] end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/relayer/irc/user.rb', line 11 def to_s @nick end |