Sha256: 71a6fa8fe89ef0ce71a41d6d800d81ed78326a0cc579bb6074b9796b40085f17

Contents?: true

Size: 484 Bytes

Versions: 5

Compression:

Stored size: 484 Bytes

Contents

class IRC
  class Sender
    attr_accessor :nick, :user, :host

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

    def server?
      @server
    end

    def user?
      !@server
    end

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

    def empty?
      to_s.empty?
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
on_irc-2.1.5 lib/on_irc/sender.rb
on_irc-2.1.4 lib/on_irc/sender.rb
on_irc-2.1.3 lib/on_irc/sender.rb
on_irc-2.1.1 lib/on_irc/sender.rb
on_irc-2.1.0 lib/on_irc/sender.rb