Class: Marvin::Parsers::Prefixes::HostMask

Inherits:
Object
  • Object
show all
Defined in:
lib/marvin/parsers/prefixes/host_mask.rb

Overview

A Generic host mask prefix for a message.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#hostObject

Returns the value of attribute host.



6
7
8
# File 'lib/marvin/parsers/prefixes/host_mask.rb', line 6

def host
  @host
end

#nickObject

Returns the value of attribute nick.



6
7
8
# File 'lib/marvin/parsers/prefixes/host_mask.rb', line 6

def nick
  @nick
end

#userObject

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_hashObject

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_sObject

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