lib/ircp/message.rb in ircp-1.1.3 vs lib/ircp/message.rb in ircp-1.1.4
- old
+ new
@@ -8,12 +8,13 @@
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]
+ @command = options[:command] || args.shift
@params = args + Array(options[:params])
+ yield self if block_given?
end
def inspect
variables = instance_variables.map { |name| "#{name}=#{instance_variable_get(name).inspect}" }
variables.unshift "#{self.class}"
@@ -32,10 +33,10 @@
last.insert 0, ':' if !last.start_with?(':') && last.include?(' ')
@params << last
end
tokens += @params
- msg = tokens.map { |token| token.to_s } .reject { |token| token.empty? }.join(' ')
+ msg = tokens.map { |token| token.to_s }.reject { |token| token.empty? }.join(' ')
msg << CRLF unless msg.end_with?(CRLF)
msg
end
alias_method :to_s, :to_irc
end