Skip to content

Commit bfa1f21

Browse files
committed
Add docstrings for SortedSet#from, #up_to, #above, #below, #between
1 parent a036e5a commit bfa1f21

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/hamster/sorted_set.rb

+23
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,10 @@ def intersect?(other)
528528
def_delegator :self, :group_by, :group
529529
def_delegator :self, :group_by, :classify
530530

531+
# With a block, yield all the items which are "higher" than `item` (as defined
532+
# by the set's comparator). Otherwise, return them as a new `SortedSet`.
533+
#
534+
# @param item [Object]
531535
def above(item, &block)
532536
if block_given?
533537
@node.each_greater(item, @comparator, false, &block)
@@ -536,6 +540,10 @@ def above(item, &block)
536540
end
537541
end
538542

543+
# With a block, yield all the items which are "higher" than `item` (as defined
544+
# by the set's comparator). Otherwise, return them as a new `SortedSet`.
545+
#
546+
# @param item [Object]
539547
def below(item, &block)
540548
if block_given?
541549
@node.each_less(item, @comparator, false, &block)
@@ -544,6 +552,11 @@ def below(item, &block)
544552
end
545553
end
546554

555+
# With a block, yield all the items which are "higher" or equal to `item`
556+
# (as determined by the set's comparator). Otherwise, return them as a new
557+
# `SortedSet`.
558+
#
559+
# @param item [Object]
547560
def from(item, &block)
548561
if block_given?
549562
@node.each_greater(item, @comparator, true, &block)
@@ -552,6 +565,10 @@ def from(item, &block)
552565
end
553566
end
554567

568+
# With a block, yield all the items which are "lower" than `item` (as defined
569+
# by the set's comparator). Otherwise, return them as a new `SortedSet`.
570+
#
571+
# @param item [Object]
555572
def up_to(item, &block)
556573
if block_given?
557574
@node.each_less(item, @comparator, true, &block)
@@ -560,6 +577,12 @@ def up_to(item, &block)
560577
end
561578
end
562579

580+
# With a block, yield all the items which are equal or higher than `from` and
581+
# equal or less than `to` (as determined by the set's comparator). Otherwise,
582+
# return the specified range of items as a new `SortedSet`.
583+
#
584+
# @param from [Object]
585+
# @param to [Object]
563586
def between(from, to, &block)
564587
if block_given?
565588
@node.each_between(from, to, @comparator, &block)

0 commit comments

Comments
 (0)