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(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

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#nicknameObject

Returns the value of attribute nickname.



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

def nickname
  @nickname
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
# File 'lib/marvin/parsers/prefixes/host_mask.rb', line 15

def to_hash
  {:nick => @nickname.freeze, :ident => @user.freeze, :host => @host.freeze}
end

#to_sObject

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