Skip to content

Commit 8fdd7d4

Browse files
committed
ruby docs
1 parent 051cb97 commit 8fdd7d4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/fromarray.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def initialize(array)
3232
end
3333

3434
# Return the number of elements in this stream.
35+
# This is a terminal operation.
3536
def count
3637
@array.length
3738
end
@@ -43,6 +44,7 @@ def count
4344
# collected = stream.filter {|num| num % 2 == 0}.collect
4445
# puts collected # [2, 4]
4546
#
47+
# This is an intermediary operation.
4648
# +condition+:: Ruby Block taking one parameter (the stream element) and
4749
# returning a boolean check on it.
4850
def filter(&condition)
@@ -60,6 +62,7 @@ def filter(&condition)
6062
# collected = stream.map {|num| num.to_s}.collect
6163
# puts collected # ['1', '2', '3']
6264
#
65+
# This is an intermediary operation.
6366
# +function+:: Ruby Block function taking one parameter
6467
# (the element in the stream).
6568
def map(&function)
@@ -71,6 +74,7 @@ def map(&function)
7174
end
7275

7376
# Remove all the duplicates from the stream.
77+
# This is an intermediary operation.
7478
def distinct
7579
unique = []
7680
@array.each do |val|
@@ -80,6 +84,7 @@ def distinct
8084
end
8185

8286
# Skip the first n elements of the stream.
87+
# This is an intermediary operation.
8388
# +count+:: Number of elements to skip from the beginning of the stream.
8489
def skip(count)
8590
raise ArgumentError, 'count has to be positive integer' unless count.positive? and count.is_a? Integer
@@ -92,6 +97,7 @@ def skip(count)
9297
end
9398

9499
# Collect the stream's data into an array and return it.
100+
# This is a terminal operation.
95101
def collect
96102
@array.dup
97103
end

0 commit comments

Comments
 (0)