@@ -239,13 +239,13 @@ class IMAP
239
239
# These methods do not modify +self+.
240
240
#
241
241
# - #| (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 .
243
243
# - #& (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 .
245
245
# - #- (aliased as #difference): Returns a copy of +self+ with all members
246
- # in the other object removed.
246
+ # in the other set removed.
247
247
# - #^ (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.
249
249
# - #~ (aliased as #complement): Returns a new set containing all members
250
250
# that are not in +self+
251
251
# - #limit: Returns a copy of +self+ which has replaced <tt>*</tt> with a
@@ -261,7 +261,7 @@ class IMAP
261
261
# - #add (aliased as #<<): Adds a given element to the set; returns +self+.
262
262
# - #add?: If the given element is not fully included the set, adds it and
263
263
# 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+.
265
265
# - #complement!: Replaces the contents of the set with its own #complement.
266
266
#
267
267
# <i>Order preserving:</i>
@@ -285,7 +285,8 @@ class IMAP
285
285
# - #delete_at: Removes the number at a given offset.
286
286
# - #slice!: Removes the number or consecutive numbers at a given offset or
287
287
# 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+.
289
290
# - #limit!: Replaces <tt>*</tt> with a given maximum value and removes all
290
291
# members over that maximum; returns +self+.
291
292
#
@@ -820,33 +821,31 @@ def slice!(index, length = nil)
820
821
deleted
821
822
end
822
823
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
824
825
# set, and returns +self+.
825
826
#
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.
830
830
#
831
- # #string will be regenerated after all inputs have been merged.
831
+ # #string will be regenerated after all sets have been merged.
832
832
#
833
833
# 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
836
836
normalize!
837
837
end
838
838
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+.
841
841
#
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.
846
845
#
847
846
# Related: #difference
848
- def subtract ( *objects )
849
- tuples_subtract input_to_tuples objects
847
+ def subtract ( *sets )
848
+ tuples_subtract input_to_tuples sets
850
849
normalize!
851
850
end
852
851
@@ -1397,19 +1396,19 @@ def input_to_tuple(entry)
1397
1396
end
1398
1397
end
1399
1398
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 }
1408
1407
when nil then [ ]
1409
1408
else
1410
1409
raise DataFormatError ,
1411
1410
"expected nz-number, range, string, or enumerable; " \
1412
- "got %p" % [ obj ]
1411
+ "got %p" % [ set ]
1413
1412
end
1414
1413
end
1415
1414
0 commit comments