Class: IRC::Sender

Inherits:
Object
  • Object
show all
Defined in:
lib/on_irc/sender.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Sender

Returns a new instance of Sender.



5
6
7
8
9
10
11
12
13
# File 'lib/on_irc/sender.rb', line 5

def initialize(string)
  if string =~ /^([^!]+)!([^@]+)@(.+)$/
    @nick, @user, @host = $1, $2, $3
    @server = false
  else
    @host = string
    @server = true
  end
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



3
4
5
# File 'lib/on_irc/sender.rb', line 3

def host
  @host
end

#nickObject

Returns the value of attribute nick.



3
4
5
# File 'lib/on_irc/sender.rb', line 3

def nick
  @nick
end

#userObject

Returns the value of attribute user.



3
4
5
# File 'lib/on_irc/sender.rb', line 3

def user
  @user
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/on_irc/sender.rb', line 27

def empty?
  to_s.empty?
end

#server?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/on_irc/sender.rb', line 15

def server?
  @server
end

#to_sObject



23
24
25
# File 'lib/on_irc/sender.rb', line 23

def to_s
  @server ? @host : @nick + '!' + @user + '@' + @host
end

#user?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/on_irc/sender.rb', line 19

def user?
  !@server
end