Sha256: fbe9d67e6dc3be8b5ebade9c444558f2b1f64533d4b5708daad2629f28b2b460

Contents?: true

Size: 810 Bytes

Versions: 12

Compression:

Stored size: 810 Bytes

Contents

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

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
Sutto-marvin-0.1.20081120 lib/marvin/parsers/prefixes/host_mask.rb
Sutto-marvin-0.2.0 lib/marvin/parsers/prefixes/host_mask.rb
Sutto-marvin-0.2.1 lib/marvin/parsers/prefixes/host_mask.rb
Sutto-marvin-0.2.2 lib/marvin/parsers/prefixes/host_mask.rb
Sutto-marvin-0.2.3 lib/marvin/parsers/prefixes/host_mask.rb
Sutto-marvin-0.2.4 lib/marvin/parsers/prefixes/host_mask.rb
Sutto-marvin-0.3.0 lib/marvin/parsers/prefixes/host_mask.rb
Sutto-marvin-0.3.2 lib/marvin/parsers/prefixes/host_mask.rb
Sutto-marvin-0.3.3 lib/marvin/parsers/prefixes/host_mask.rb
Sutto-marvin-0.3.4 lib/marvin/parsers/prefixes/host_mask.rb
Sutto-marvin-0.4.0 lib/marvin/parsers/prefixes/host_mask.rb
jeffrafter-marvin-0.1.20081120 lib/marvin/parsers/prefixes/host_mask.rb