Sha256: 6e1909442d4b5a69a2762cbb192994c28a198f16facfee0381356b646879b697

Contents?: true

Size: 840 Bytes

Versions: 7

Compression:

Stored size: 840 Bytes

Contents

module Marvin
  module Parsers
    module Prefixes
      # A Generic host mask prefix for a message.
      class HostMask
        attr_accessor :nick, :user, :host
        
        def initialize(nick = nil, user = nil, host = nil)
          @nick = nick || ""
          @user = user || ""
          @host = host || ""
        end
        
        # Convert it to a usable hash.
        def to_hash
          {
            :nick => @nick.dup.freeze,
            :ident => @user.dup.freeze,
            :host => @host.dup.freeze
          }
        end
        
        # Converts it back to a nicer form / a string.
        def to_s
          str = ""
          str << @nick.to_s
          str << "!#{@user}" unless @user.blank?
          str << "@#{@host}" unless @host.blank?
          str
        end
        
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
Sutto-marvin-0.8.0.0 lib/marvin/parsers/prefixes/host_mask.rb
Sutto-marvin-0.8.0.1 lib/marvin/parsers/prefixes/host_mask.rb
marvin-0.8.2 lib/marvin/parsers/prefixes/host_mask.rb
marvin-0.8.1 lib/marvin/parsers/prefixes/host_mask.rb
marvin-0.8.0.2 lib/marvin/parsers/prefixes/host_mask.rb
marvin-0.8.0.1 lib/marvin/parsers/prefixes/host_mask.rb
marvin-0.8.0.0 lib/marvin/parsers/prefixes/host_mask.rb