Class: Flexo::Data::Hostmask

Inherits:
Object
  • Object
show all
Defined in:
lib/flexo/data.rb

Overview

For added fun, we have a small, separate class for hostmasks. And, being very creative, we call it… Data::Hostmask!

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(nickname, username, hostname) ⇒ Hostmask

The only function in this class. When instanciated, this populates some instance variables with sensible values, and then allow us to access those using attr_readers



89
90
91
92
93
94
# File 'lib/flexo/data.rb', line 89

def initialize(nickname, username, hostname)
  @nickname = nickname
  @username = username
  @hostname = hostname
  @hostmask = "#{@nickname}!#{@username}@#{@hostname}".sub(/!?@?$/, '')
end

Instance Attribute Details

#hostmaskObject (readonly) Also known as: mask

Returns the value of attribute hostmask.



71
72
73
# File 'lib/flexo/data.rb', line 71

def hostmask
  @hostmask
end

#hostnameObject (readonly) Also known as: host, ip

Returns the value of attribute hostname.



69
70
71
# File 'lib/flexo/data.rb', line 69

def hostname
  @hostname
end

#nicknameObject (readonly) Also known as: nick, from, by

Returns the value of attribute nickname.



68
69
70
# File 'lib/flexo/data.rb', line 68

def nickname
  @nickname
end

#usernameObject (readonly) Also known as: user, ident

Returns the value of attribute username.



70
71
72
# File 'lib/flexo/data.rb', line 70

def username
  @username
end

Instance Method Details

#inspectObject



96
97
98
# File 'lib/flexo/data.rb', line 96

def inspect
  "#<#{self.class}:#{@hostmask}>"
end