Method: Net::IMAP#list
- Defined in:
- lib/net/imap.rb
#list(refname, mailbox) ⇒ Object
Sends a LIST command, and returns a subset of names from the complete set of all names available to the client. refname provides a context (for instance, a base directory in a directory-based mailbox hierarchy). mailbox specifies a mailbox or (via wildcards) mailboxes under that context. Two wildcards may be used in mailbox: ‘*’, which matches all characters including the hierarchy delimiter (for instance, ‘/’ on a UNIX-hosted directory-based mailbox hierarchy); and ‘%’, which matches all characters except the hierarchy delimiter.
If refname is empty, mailbox is used directly to determine which mailboxes to match. If mailbox is empty, the root name of refname and the hierarchy delimiter are returned.
The return value is an array of Net::IMAP::MailboxList. For example:
imap.create("foo/bar")
imap.create("foo/baz")
p imap.list("", "foo/%")
#=> [#<Net::IMAP::MailboxList attr=[:Noselect], delim="/", name="foo/">, \\
#<Net::IMAP::MailboxList attr=[:Noinferiors, :Marked], delim="/", name="foo/bar">, \\
#<Net::IMAP::MailboxList attr=[:Noinferiors], delim="/", name="foo/baz">]
540 541 542 543 544 545 |
# File 'lib/net/imap.rb', line 540 def list(refname, mailbox) synchronize do send_command("LIST", refname, mailbox) return @responses.delete("LIST") end end |