Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcda6451

Browse files
authored
🔀 Merge pull request#420 from ruby/seqset-docs
📚 Impove SequenceSet docs
2 parents7d67c66 +6ce9f1b commitcda6451

File tree

1 file changed

+62
-60
lines changed

1 file changed

+62
-60
lines changed

‎lib/net/imap/sequence_set.rb‎

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -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
318319
class <<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
690694
aliascomplement:~
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-
defadd(object)
702-
tuple_addinput_to_tupleobject
705+
defadd(element)
706+
tuple_addinput_to_tupleelement
703707
normalize!
704708
end
705709
alias <<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-
defappend(object)
715+
defappend(entry)
712716
modifying!
713-
tuple=input_to_tupleobject
717+
tuple=input_to_tupleentry
714718
entry=tuple_to_strtuple
715719
stringunlessempty?# write @string before tuple_add
716720
tuple_addtuple
717721
@string= -(@string ?"#{@string},#{entry}" :entry)
718722
self
719723
end
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-
defadd?(object)
730-
addobjectunlessinclude?object
733+
defadd?(element)
734+
addelementunlessinclude?element
731735
end
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-
defdelete(object)
742-
tuple_subtractinput_to_tupleobject
745+
defdelete(element)
746+
tuple_subtractinput_to_tupleelement
743747
normalize!
744748
end
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-
defdelete?(object)
779-
tuple=input_to_tupleobject
782+
defdelete?(element)
783+
tuple=input_to_tupleelement
780784
iftuple.first ==tuple.last
781785
returnunlessinclude_tuple?tuple
782786
tuple_subtracttuple
@@ -820,33 +824,31 @@ def slice!(index, length = nil)
820824
deleted
821825
end
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-
defmerge(*inputs)
835-
tuples_addinput_to_tuplesinputs
837+
defmerge(*sets)
838+
tuples_addinput_to_tuplessets
836839
normalize!
837840
end
838841

839-
# Removes all of the elements that appear in any of the given +objects+
840-
#fromthe 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-
defsubtract(*objects)
849-
tuples_subtractinput_to_tuplesobjects
850+
defsubtract(*sets)
851+
tuples_subtractinput_to_tuplessets
850852
normalize!
851853
end
852854

@@ -1386,30 +1388,30 @@ def initialize_dup(other)
13861388
super
13871389
end
13881390

1389-
definput_to_tuple(obj)
1390-
obj=input_try_convertobj
1391-
caseobj
1392-
when *STARS,Integerthen[int=to_tuple_int(obj),int]
1393-
whenRangethenrange_to_tuple(obj)
1394-
whenStringthenstr_to_tuple(obj)
1391+
definput_to_tuple(entry)
1392+
entry=input_try_convertentry
1393+
caseentry
1394+
when *STARS,Integerthen[int=to_tuple_int(entry),int]
1395+
whenRangethenrange_to_tuple(entry)
1396+
whenStringthenstr_to_tuple(entry)
13951397
else
1396-
raiseDataFormatError,"expected number or range, got %p" %[obj]
1398+
raiseDataFormatError,"expected number or range, got %p" %[entry]
13971399
end
13981400
end
13991401

1400-
definput_to_tuples(obj)
1401-
obj=input_try_convertobj
1402-
caseobj
1403-
when *STARS,Integer,Rangethen[input_to_tuple(obj)]
1404-
whenStringthenstr_to_tuplesobj
1405-
whenSequenceSetthenobj.tuples
1406-
whenSetthenobj.map{[to_tuple_int(_1)] *2}
1407-
whenArraythenobj.flat_map{input_to_tuples_1}
1402+
definput_to_tuples(set)
1403+
set=input_try_convertset
1404+
caseset
1405+
when *STARS,Integer,Rangethen[input_to_tuple(set)]
1406+
whenStringthenstr_to_tuplesset
1407+
whenSequenceSetthenset.tuples
1408+
whenSetthenset.map{[to_tuple_int(_1)] *2}
1409+
whenArraythenset.flat_map{input_to_tuples_1}
14081410
whennilthen[]
14091411
else
14101412
raiseDataFormatError,
14111413
"expected nz-number, range, string, or enumerable; " \
1412-
"got %p" %[obj]
1414+
"got %p" %[set]
14131415
end
14141416
end
14151417

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp