@@ -39,12 +39,32 @@ def initialize(tag: nil, uid: nil, data: nil)
39
39
# numbers or UIDs, +to_a+ returns that set as an array of integers.
40
40
#
41
41
# 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.
44
44
#
45
45
# Note that SearchResult also implements +to_a+, so it can be used without
46
46
# 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
48
68
49
69
##
50
70
# attr_reader: tag
@@ -161,6 +181,8 @@ def initialize(range:, results:)
161
181
#
162
182
# See also: ESearchResult#to_a.
163
183
def to_a ; results &.numbers || [ ] end
184
+
185
+ alias to_sequence_set results
164
186
end
165
187
166
188
# :call-seq: partial -> PartialResult or nil
0 commit comments