@@ -39,12 +39,32 @@ def initialize(tag: nil, uid: nil, data: nil)
3939 # numbers or UIDs, +to_a+ returns that set as an array of integers.
4040 #
4141 # When both #all and #partial are +nil+, either because the server
42- # returned no results or because +ALL+ and +PARTIAL+ were not included in
43- # the IMAP#search +RETURN+ options, #to_a returns an empty array.
42+ # returned no results or because neither +ALL+ or +PARTIAL+ were included
43+ # in the IMAP#search +RETURN+ options, #to_a returns an empty array.
4444 #
4545 # Note that SearchResult also implements +to_a+, so it can be used without
4646 # checking if the server returned +SEARCH+ or +ESEARCH+ data.
47- def to_a ; all &.numbers || partial &.to_a || [ ] end
47+ #
48+ # Related: #to_sequence_set, #all, #partial
49+ def to_a ; to_sequence_set . numbers end
50+
51+ # :call-seq: to_sequence_set -> SequenceSet or nil
52+ #
53+ # When either #all or #partial contains a SequenceSet of message sequence
54+ # numbers or UIDs, +to_sequence_set+ returns that sequence set.
55+ #
56+ # When both #all and #partial are +nil+, either because the server
57+ # returned no results or because neither +ALL+ or +PARTIAL+ were included
58+ # in the IMAP#search +RETURN+ options, #to_sequence_set returns
59+ # SequenceSet.empty.
60+ #
61+ # Note that SearchResult also implements +to_sequence_set+, so it can be
62+ # used without checking if the server returned +SEARCH+ or +ESEARCH+ data.
63+ #
64+ # Related: #to_a, #all, #partial
65+ def to_sequence_set
66+ all || partial &.to_sequence_set || SequenceSet . empty
67+ end
4868
4969 ##
5070 # attr_reader: tag
@@ -161,6 +181,8 @@ def initialize(range:, results:)
161181 #
162182 # See also: ESearchResult#to_a.
163183 def to_a ; results &.numbers || [ ] end
184+
185+ alias to_sequence_set results
164186 end
165187
166188 # :call-seq: partial -> PartialResult or nil
0 commit comments