Sha256: 5f98951e5d03ec451c88ad0f80d28cf0d2fdc9e783a7eb5b6491fe120b7cde6f

Contents?: true

Size: 857 Bytes

Versions: 1

Compression:

Stored size: 857 Bytes

Contents

module Ircp
  class Prefix
    attr_accessor :raw, :servername, :nick, :user, :host

    def initialize(options = {})
      @raw = options[:raw]
      @servername = options[:servername]
      @nick = options[:nick]
      @user = options[:user]
      @host = options[:host]
    end

    def empty?
      to_s.empty?
    end

    def inspect
      variables = instance_variables.map { |name| "#{name.inspect}=#{instance_variable_get(name).inspect}" }
      variables.unshift "#{self.class}"
      "<#{variables.join ' '}>"
    end

    def to_s
      return @raw unless @raw.nil?

      if @servername
        ":#{servername}"
      else
        tokens = []
        tokens.push ":#{@nick}" unless @nick.nil?
        tokens.push "!#{@user}" unless @user.nil?
        tokens.push "@#{@host}" unless @host.nil?
        tokens.join ''
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ircp-0.0.2 lib/ircp/prefix.rb