Class: Marvin::Parsers::Prefixes::HostMask
- Inherits:
-
Object
- Object
- Marvin::Parsers::Prefixes::HostMask
- Defined in:
- lib/marvin/parsers/prefixes/host_mask.rb
Overview
A Generic host mask prefix for a message.
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#nickname ⇒ Object
Returns the value of attribute nickname.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(nickname = nil, user = nil, host = nil) ⇒ HostMask
constructor
A new instance of HostMask.
-
#to_hash ⇒ Object
Convert it to a usable hash.
-
#to_s ⇒ Object
Converts it back to a nicer form / a string.
Constructor Details
#initialize(nickname = nil, user = nil, host = nil) ⇒ HostMask
Returns a new instance of HostMask.
8 9 10 11 12 |
# File 'lib/marvin/parsers/prefixes/host_mask.rb', line 8 def initialize(nickname = nil, user = nil, host = nil) self.nickname = nickname || "" self.user = user || "" self.host = host || "" end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
6 7 8 |
# File 'lib/marvin/parsers/prefixes/host_mask.rb', line 6 def host @host end |
#nickname ⇒ Object
Returns the value of attribute nickname.
6 7 8 |
# File 'lib/marvin/parsers/prefixes/host_mask.rb', line 6 def nickname @nickname end |
#user ⇒ Object
Returns the value of attribute user.
6 7 8 |
# File 'lib/marvin/parsers/prefixes/host_mask.rb', line 6 def user @user end |
Instance Method Details
#to_hash ⇒ Object
Convert it to a usable hash.
15 16 17 |
# File 'lib/marvin/parsers/prefixes/host_mask.rb', line 15 def to_hash {:nick => @nickname.freeze, :ident => @user.freeze, :host => @host.freeze} end |
#to_s ⇒ Object
Converts it back to a nicer form / a string.
20 21 22 23 24 25 |
# File 'lib/marvin/parsers/prefixes/host_mask.rb', line 20 def to_s str = "" str << @nickname.to_s str << "!#{@user}" unless @user.blank? str << "@#{@host}" unless @host.blank? end |