class Net::IMAP

def responses(type = nil)

Related: #clear_responses, #response_handlers, #greeting

handle all response codes.
return the TaggedResponse directly, #add_response_handler must be used to
ResponseCode#data on tagged responses. Although some command methods do
TaggedResponse#data is not saved to #responses, nor is any

"+OK+", "+NO+", "+BAD+", "+BYE+", or "+PREAUTH+".
attached to. ResponseText will be accessible by its response types:
of their own, but are used as "tags" on the ResponseText object they are
Only non-+nil+ data is stored. Many important response codes have no data

the block, or use #clear_responses.
consume more memory. Update or clear the responses hash or arrays inside
unhandled server responses, which must be pruned or they will continually
mailbox with #select or #examine. Long-lived connections can receive many
Previously unhandled responses are automatically cleared before entering a

raise ArgumentError unless a block is given.
Calling without a block is unsafe and deprecated. Future releases will

response type arrays outside of the block is unsafe.
until the block completes. Accessing either the response hash or its
The receiver thread and response_handlers cannot process new responses
*Note:* Access to the responses hash is synchronized for thread-safety.
>>>

#=> 968263756
p imap.responses("UIDVALIDITY", &:last)
#=> 2
p imap.responses("EXISTS", &:last)
imap.select("inbox")

For example:

of responses for that type.
yield the entire responses hash. Call with +type+ to yield only the array
and ResponseCode#data keyed by ResponseCode#name. Call without +type+ to
non-+nil+ UntaggedResponse#data keyed by UntaggedResponse#name
Unhandled responses are stored in a hash, with arrays of

Yields unhandled responses and returns the result of the block.

responses(type) {|array| ...} -> block result
responses {|hash| ...} -> block result
:call-seq:
def responses(type = nil)
  if block_given?
    synchronize { yield(type ? @responses[type.to_s.upcase] : @responses) }
  elsif type
    raise ArgumentError, "Pass a block or use #clear_responses"
  else
    # warn("DEPRECATED: pass a block or use #clear_responses", uplevel: 1)
    @responses
  end
end