imap.rb/lib/imap_server/server_message.rb
2022-12-09 14:38:24 +01:00

33 lines
665 B
Ruby

class ImapServer
# class ServerMessages < Array
# def initialize(crlf: true, tag: true)
# @crlf = crlf
# @tag = tag
# super()
# end
# def <<(item)
# if item.is_a?(String)
# super(ServerMessage.new(item, crlf: @crlf, tag: @tag))
# else
# super(item)
# end
# end
# end
class ServerMessage < String
def initialize(string, crlf: true, tag: "*")
@crlf = crlf
@tag = tag
super(string)
end
def to_s
output = super()
output = "#{output}\r\n" if @crlf && !output.end_with?("\r\r")
output = "#{@tag} #{output}" if @tag
output
end
end
end