Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/net/imap/sequence_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,9 @@ def disjoint?(other)
# Related: #min, #minmax, #slice
def max(count = nil, star: :*)
if count
count = Integer(count.to_int)
raise ArgumentError, 'negative count' if count < 0
return remain_frozen_empty if count == 0
if cardinality <= count
frozen? ? self : dup
else
Expand All @@ -812,6 +815,8 @@ def max(count = nil, star: :*)
# Related: #max, #minmax, #slice
def min(count = nil, star: :*)
if count
count = Integer(count.to_int)
raise ArgumentError, 'negative count' if count < 0
slice(0...count) || remain_frozen_empty
elsif (val = min_num)
val != STAR_INT ? val : star
Expand Down