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.
-
#nick ⇒ Object
Returns the value of attribute nick.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(nick = 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(nick = 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(nick = nil, user = nil, host = nil) @nick = nick || "" @user = user || "" @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 |
#nick ⇒ Object
Returns the value of attribute nick.
6 7 8 |
# File 'lib/marvin/parsers/prefixes/host_mask.rb', line 6 def nick @nick 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 18 19 20 21 |
# File 'lib/marvin/parsers/prefixes/host_mask.rb', line 15 def to_hash { :nick => @nick.dup.freeze, :ident => @user.dup.freeze, :host => @host.dup.freeze } end |
#to_s ⇒ Object
Converts it back to a nicer form / a string.
24 25 26 27 28 29 30 |
# File 'lib/marvin/parsers/prefixes/host_mask.rb', line 24 def to_s str = "" str << @nick.to_s str << "!#{@user}" unless @user.blank? str << "@#{@host}" unless @host.blank? str end |