@@ -174,7 +174,7 @@ class IMAP
174174#
175175# <i>Set membership:</i>
176176# - #include? (aliased as #member?):
177- # Returns whether a givenobject (nz-number, range, or <tt>*</tt>) is
177+ # Returns whether a givenelement (nz-number, range, or <tt>*</tt>) is
178178# contained by the set.
179179# - #include_star?: Returns whether the set contains <tt>*</tt>.
180180#
@@ -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 otherobject .
242+ # from +self+ with all members from the otherset .
243243# - #& (aliased as #intersection): Returns a new set containing all members
244- # common to +self+ and the otherobject .
244+ # common to +self+ and the otherset .
245245# - #- (aliased as #difference): Returns a copy of +self+ with all members
246- # in the otherobject removed.
246+ # in the otherset removed.
247247# - #^ (aliased as #xor): Returns a new set containing all members from
248- # +self+ and the otherobject except those common to both.
248+ # +self+ and the otherset 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
@@ -258,17 +258,17 @@ class IMAP
258258#
259259# These methods always update #string to be fully sorted and coalesced.
260260#
261- # - #add (aliased as #<<): Adds a givenobject to the set; returns +self+.
262- # - #add?: If the givenobject is notan element in the set, adds it and
261+ # - #add (aliased as #<<): Adds a givenelement to the set; returns +self+.
262+ # - #add?: If the givenelement is notfully 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>
268268#
269269# These methods _may_ cause #string to not be sorted or coalesced.
270270#
271- # - #append: Addsa givenobject to the set, appending it to the existing
271+ # - #append: Addsthe givenentry to the set, appending it to the existing
272272# string, and returns +self+.
273273# - #string=: Assigns a new #string value and replaces #elements to match.
274274# - #replace: Replaces the contents of the set with the contents
@@ -279,13 +279,14 @@ class IMAP
279279# sorted and coalesced.
280280#
281281# - #clear: Removes all elements in the set; returns +self+.
282- # - #delete: Removes a givenobject from the set; returns +self+.
283- # - #delete?: If the givenobject isan element in the set, removes it and
282+ # - #delete: Removes a givenelement from the set; returns +self+.
283+ # - #delete?: If the givenelement isincluded in the set, removes it and
284284# returns it; otherwise, returns +nil+.
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#
@@ -318,9 +319,12 @@ class SequenceSet
318319class <<self
319320
320321# :call-seq:
321- # SequenceSet[*values ] -> valid frozen sequence set
322+ # SequenceSet[*inputs ] -> valid frozen sequence set
322323#
323- # Returns a frozen SequenceSet, constructed from +values+.
324+ # Returns a frozen SequenceSet, constructed from +inputs+.
325+ #
326+ # When only a single valid frozen SequenceSet is given, that same set is
327+ # returned.
324328#
325329# An empty SequenceSet is invalid and will raise a DataFormatError.
326330#
@@ -690,16 +694,16 @@ def ~; remain_frozen dup.complement! end
690694alias complement :~
691695
692696# :call-seq:
693- # add(object ) -> self
697+ # add(element ) -> self
694698# self << other -> self
695699#
696700# Adds a range or number to the set and returns +self+.
697701#
698702# #string will be regenerated. Use #merge to add many elements at once.
699703#
700704# Related: #add?, #merge, #union
701- def add ( object )
702- tuple_add input_to_tuple object
705+ def add ( element )
706+ tuple_add input_to_tuple element
703707normalize!
704708end
705709alias <<add
@@ -708,38 +712,38 @@ def add(object)
708712#
709713# Unlike #add, #merge, or #union, the new value is appended to #string.
710714# This may result in a #string which has duplicates or is out-of-order.
711- def append ( object )
715+ def append ( entry )
712716modifying!
713- tuple = input_to_tuple object
717+ tuple = input_to_tuple entry
714718entry = tuple_to_str tuple
715719string unless empty? # write @string before tuple_add
716720tuple_add tuple
717721@string = -( @string ?"#{ @string } ,#{ entry } " :entry )
718722self
719723end
720724
721- # :call-seq: add?(object ) -> self or nil
725+ # :call-seq: add?(element ) -> self or nil
722726#
723727# Adds a range or number to the set and returns +self+. Returns +nil+
724- # when theobject is already included in the set.
728+ # when theelement is already included in the set.
725729#
726730# #string will be regenerated. Use #merge to add many elements at once.
727731#
728732# Related: #add, #merge, #union, #include?
729- def add? ( object )
730- add object unless include? object
733+ def add? ( element )
734+ add element unless include? element
731735end
732736
733- # :call-seq: delete(object ) -> self
737+ # :call-seq: delete(element ) -> self
734738#
735739# Deletes the given range or number from the set and returns +self+.
736740#
737741# #string will be regenerated after deletion. Use #subtract to remove
738742# many elements at once.
739743#
740744# Related: #delete?, #delete_at, #subtract, #difference
741- def delete ( object )
742- tuple_subtract input_to_tuple object
745+ def delete ( element )
746+ tuple_subtract input_to_tuple element
743747normalize!
744748end
745749
@@ -775,8 +779,8 @@ def delete(object)
775779# #string will be regenerated after deletion.
776780#
777781# Related: #delete, #delete_at, #subtract, #difference, #disjoint?
778- def delete? ( object )
779- tuple = input_to_tuple object
782+ def delete? ( element )
783+ tuple = input_to_tuple element
780784if tuple . first ==tuple . last
781785return unless include_tuple? tuple
782786tuple_subtract tuple
@@ -820,33 +824,31 @@ def slice!(index, length = nil)
820824deleted
821825end
822826
823- # Merges all of the elements that appear in any of the +inputs + into the
827+ # Merges all of the elements that appear in any of the +sets + into the
824828# set, and returns +self+.
825829#
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.
830+ # The +sets+ may be any objects that would be accepted by ::new: non-zero
831+ # 32 bit unsigned integers, ranges, <tt>sequence-set</tt> formatted
832+ # strings, other sequence sets, or enumerables containing any of these.
830833#
831- # #string will be regenerated after allinputs have been merged.
834+ # #string will be regenerated after allsets have been merged.
832835#
833836# Related: #add, #add?, #union
834- def merge ( *inputs )
835- tuples_add input_to_tuples inputs
837+ def merge ( *sets )
838+ tuples_add input_to_tuples sets
836839normalize!
837840end
838841
839- # Removes all of the elements that appear in any of the given +objects+
840- #from the set, and returns +self+.
842+ # Removes all of the elements that appear in any of the given +sets+ from
843+ # the set, and returns +self+.
841844#
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.
845+ # The +sets+ may be any objects that would be accepted by ::new: non-zero
846+ # 32 bit unsigned integers, ranges, <tt>sequence-set</tt> formatted
847+ # strings, other sequence sets, or enumerables containing any of these.
846848#
847849# Related: #difference
848- def subtract ( *objects )
849- tuples_subtract input_to_tuples objects
850+ def subtract ( *sets )
851+ tuples_subtract input_to_tuples sets
850852normalize!
851853end
852854
@@ -1386,30 +1388,30 @@ def initialize_dup(other)
13861388super
13871389end
13881390
1389- def input_to_tuple ( obj )
1390- obj = input_try_convert obj
1391- case obj
1392- when *STARS , Integer then [ int = to_tuple_int ( obj ) , int ]
1393- when Range then range_to_tuple ( obj )
1394- when String then str_to_tuple ( obj )
1391+ def input_to_tuple ( entry )
1392+ entry = input_try_convert entry
1393+ case entry
1394+ when *STARS , Integer then [ int = to_tuple_int ( entry ) , int ]
1395+ when Range then range_to_tuple ( entry )
1396+ when String then str_to_tuple ( entry )
13951397else
1396- raise DataFormatError , "expected number or range, got %p" %[ obj ]
1398+ raise DataFormatError , "expected number or range, got %p" %[ entry ]
13971399end
13981400end
13991401
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 }
1402+ def input_to_tuples ( set )
1403+ set = input_try_convert set
1404+ case set
1405+ when *STARS , Integer , Range then [ input_to_tuple ( set ) ]
1406+ when String then str_to_tuples set
1407+ when SequenceSet then set . tuples
1408+ when Set then set . map { [ to_tuple_int ( _1 ) ] *2 }
1409+ when Array then set . flat_map { input_to_tuples _1 }
14081410when nil then [ ]
14091411else
14101412raise DataFormatError ,
14111413"expected nz-number, range, string, or enumerable; " \
1412- "got %p" %[ obj ]
1414+ "got %p" %[ set ]
14131415end
14141416end
14151417