Skip to content

Commit 1d99e40

Browse files
committed
📚 Consistently use "sets" or "other" vs "object"
1 parent 779f356 commit 1d99e40

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

lib/net/imap/sequence_set.rb

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -239,13 +239,13 @@ class IMAP
239239
# These methods do not modify +self+.
240240
#
241241
# - #| (aliased as #union and #+): Returns a new set combining all members
242-
# from +self+ with all members from the other object.
242+
# from +self+ with all members from the other set.
243243
# - #& (aliased as #intersection): Returns a new set containing all members
244-
# common to +self+ and the other object.
244+
# common to +self+ and the other set.
245245
# - #- (aliased as #difference): Returns a copy of +self+ with all members
246-
# in the other object removed.
246+
# in the other set removed.
247247
# - #^ (aliased as #xor): Returns a new set containing all members from
248-
# +self+ and the other object except those common to both.
248+
# +self+ and the other set except those common to both.
249249
# - #~ (aliased as #complement): Returns a new set containing all members
250250
# that are not in +self+
251251
# - #limit: Returns a copy of +self+ which has replaced <tt>*</tt> with a
@@ -261,7 +261,7 @@ class IMAP
261261
# - #add (aliased as #<<): Adds a given element to the set; returns +self+.
262262
# - #add?: If the given element is not fully included the set, adds it and
263263
# returns +self+; otherwise, returns +nil+.
264-
# - #merge: Merges multiple elements into the set; returns +self+.
264+
# - #merge: Adds all members of the given sets into this set; returns +self+.
265265
# - #complement!: Replaces the contents of the set with its own #complement.
266266
#
267267
# <i>Order preserving:</i>
@@ -285,7 +285,8 @@ class IMAP
285285
# - #delete_at: Removes the number at a given offset.
286286
# - #slice!: Removes the number or consecutive numbers at a given offset or
287287
# range of offsets.
288-
# - #subtract: Removes each given object from the set; returns +self+.
288+
# - #subtract: Removes all members of the given sets from this set; returns
289+
# +self+.
289290
# - #limit!: Replaces <tt>*</tt> with a given maximum value and removes all
290291
# members over that maximum; returns +self+.
291292
#
@@ -820,33 +821,31 @@ def slice!(index, length = nil)
820821
deleted
821822
end
822823

823-
# Merges all of the elements that appear in any of the +inputs+ into the
824+
# Merges all of the elements that appear in any of the +sets+ into the
824825
# set, and returns +self+.
825826
#
826-
# The +inputs+ may be any objects that would be accepted by ::new:
827-
# non-zero 32 bit unsigned integers, ranges, <tt>sequence-set</tt>
828-
# formatted strings, other sequence sets, or enumerables containing any of
829-
# these.
827+
# The +sets+ may be any objects that would be accepted by ::new: non-zero
828+
# 32 bit unsigned integers, ranges, <tt>sequence-set</tt> formatted
829+
# strings, other sequence sets, or enumerables containing any of these.
830830
#
831-
# #string will be regenerated after all inputs have been merged.
831+
# #string will be regenerated after all sets have been merged.
832832
#
833833
# Related: #add, #add?, #union
834-
def merge(*inputs)
835-
tuples_add input_to_tuples inputs
834+
def merge(*sets)
835+
tuples_add input_to_tuples sets
836836
normalize!
837837
end
838838

839-
# Removes all of the elements that appear in any of the given +objects+
840-
# from the set, and returns +self+.
839+
# Removes all of the elements that appear in any of the given +sets+ from
840+
# the set, and returns +self+.
841841
#
842-
# The +objects+ may be any objects that would be accepted by ::new:
843-
# non-zero 32 bit unsigned integers, ranges, <tt>sequence-set</tt>
844-
# formatted strings, other sequence sets, or enumerables containing any of
845-
# these.
842+
# The +sets+ may be any objects that would be accepted by ::new: non-zero
843+
# 32 bit unsigned integers, ranges, <tt>sequence-set</tt> formatted
844+
# strings, other sequence sets, or enumerables containing any of these.
846845
#
847846
# Related: #difference
848-
def subtract(*objects)
849-
tuples_subtract input_to_tuples objects
847+
def subtract(*sets)
848+
tuples_subtract input_to_tuples sets
850849
normalize!
851850
end
852851

@@ -1397,19 +1396,19 @@ def input_to_tuple(entry)
13971396
end
13981397
end
13991398

1400-
def input_to_tuples(obj)
1401-
obj = input_try_convert obj
1402-
case obj
1403-
when *STARS, Integer, Range then [input_to_tuple(obj)]
1404-
when String then str_to_tuples obj
1405-
when SequenceSet then obj.tuples
1406-
when Set then obj.map { [to_tuple_int(_1)] * 2 }
1407-
when Array then obj.flat_map { input_to_tuples _1 }
1399+
def input_to_tuples(set)
1400+
set = input_try_convert set
1401+
case set
1402+
when *STARS, Integer, Range then [input_to_tuple(set)]
1403+
when String then str_to_tuples set
1404+
when SequenceSet then set.tuples
1405+
when Set then set.map { [to_tuple_int(_1)] * 2 }
1406+
when Array then set.flat_map { input_to_tuples _1 }
14081407
when nil then []
14091408
else
14101409
raise DataFormatError,
14111410
"expected nz-number, range, string, or enumerable; " \
1412-
"got %p" % [obj]
1411+
"got %p" % [set]
14131412
end
14141413
end
14151414

0 commit comments

Comments
 (0)