Sha256: decefcb7b086ba9722b4579af1b0985f3fdda66467c2d2c9d9f18fa27258f62a
Contents?: true
Size: 949 Bytes
Versions: 1
Compression:
Stored size: 949 Bytes
Contents
require 'ircp/prefix' module Ircp class Message attr_accessor :raw, :prefix, :command, :params def initialize(*args) options = args.last.is_a?(Hash) ? args.pop : {} @raw = options[:raw] @prefix = options[:prefix] ? Prefix.new(options[:prefix]) : nil @command = options[:command] @params = args + Array(options[:params]) 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 if @raw.nil? || @raw.empty? tokens = [] tokens << @prefix tokens << @command @params.each { |param| tokens << param } msg = tokens.delete_if { |token| token.nil? || token.empty? }.join(' ') else msg = @raw.to_s end msg << "\r\n" unless msg.end_with?("\r\n") msg end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ircp-1.1.0 | lib/ircp/message.rb |