33 lines
665 B
Ruby
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
|