Skip to content

Commit

Permalink
🚧📚 seq-set doc updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nevans committed Nov 27, 2023
1 parent b0c56c1 commit d191357
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions lib/net/imap/sequence_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ module Net
class IMAP

##
# An IMAP {sequence
# set}[https://www.rfc-editor.org/rfc/rfc9051.html#section-4.1.1],
# is a set of message sequence numbers or unique identifier numbers
# ("UIDs"). It contains numbers and ranges of numbers. The numbers are all
# non-zero unsigned 32-bit integers and one special value, <tt>*</tt>, that
# represents the largest value in the mailbox.
# An \IMAP sequence set is a set of message sequence numbers or unique
# identifier numbers ("UIDs"). It contains numbers and ranges of numbers.
# The numbers are all non-zero unsigned 32-bit integers and one special
# value, <tt>*</tt>, that represents the largest value in the mailbox.
#
# === Creating sequence sets
#
Expand All @@ -19,7 +17,7 @@ class IMAP
#
# SequenceSet.new takes a single optional argument, which may be an IMAP
# formatted +sequence-set+ string or an enumeration of numbers and ranges.
# Use ::[] with one or more arguments to return a normalized frozen
# Use ::[] with one or more arguments to return a frozen validated
# SequenceSet.
#
# SequenceSet.new with no arguments creates an empty sequence set. But an
Expand All @@ -39,9 +37,9 @@ class IMAP
# <tt>:*</tt>, an endless range, or a range ending in <tt>-1</tt>. It will
# be converted into <tt>:*</tt> or an endless range. For example:
#
# Net::IMAP::SequenceSet["*"].to_a # => [:*]
# Net::IMAP::SequenceSet["1234:*"].to_a # => [1234..]
# Net::IMAP::SequenceSet[1234..-1].to_a # => [1234..]
# Net::IMAP::SequenceSet["*"].elements # => [:*]
# Net::IMAP::SequenceSet["1234:*"].elements # => [1234..]
# Net::IMAP::SequenceSet[1234..-1].elements # => [1234..]
# Net::IMAP::SequenceSet[1234..].to_s # => "1234:*"
# Net::IMAP::SequenceSet[1234..-1].to_s # => "1234:*"
#
Expand Down Expand Up @@ -341,12 +339,15 @@ def subtract(object)
# Net::IMAP::SequenceSet["2,5:9,6,*,12:11"].elements
# # => [2, 5..9, 11..12, :*]
#
# Related: #ranges, #numbers
# Related: #each_element, #ranges, #numbers
def elements; each_element.to_a end
alias to_a elements

# Yields each element in #elements to the block and returns self.
#
# Returns an enumerator when called without a block.
#
# Related: #elements
def each_element
return to_enum(__method__) unless block_given?
@tuples.each { yield tuple_to_el(_1, _2) }
Expand All @@ -370,12 +371,14 @@ def each_element
# Net::IMAP::SequenceSet["123,999:*,456:789"].ranges
# # => [123..123, 456..789, 999..]
#
# Related: #elements, #numbers, #to_set
# Related: #each_range, #elements, #numbers, #to_set
def ranges; each_range.to_a end

# Yields each range in #ranges to the block and returns self.
#
# Returns an enumerator when called without a block.
#
# Related: #ranges
def each_range
return to_enum(__method__) unless block_given?
@tuples.each { yield tuple_to_range(_1, _2) }
Expand Down

0 comments on commit d191357

Please sign in to comment.