-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharithmetic_sequence.rbs
More file actions
70 lines (64 loc) · 1.86 KB
/
arithmetic_sequence.rbs
File metadata and controls
70 lines (64 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# <!-- rdoc-file=enumerator.c -->
# Enumerator::ArithmeticSequence is a subclass of Enumerator, that is a
# representation of sequences of numbers with common difference. Instances of
# this class can be generated by the Range#step and Numeric#step methods.
#
# The class can be used for slicing Array (see Array#slice) or custom
# collections.
#
class Enumerator::ArithmeticSequence < Enumerator[Numeric]
# <!--
# rdoc-file=enumerator.c
# - aseq.begin -> num or nil
# -->
# Returns the number that defines the first element of this arithmetic sequence.
#
def begin: () -> Numeric?
# <!--
# rdoc-file=enumerator.c
# - aseq.end -> num or nil
# -->
# Returns the number that defines the end of this arithmetic sequence.
#
def end: () -> Numeric?
# <!--
# rdoc-file=enumerator.c
# - aseq.each {|i| block } -> aseq
# - aseq.each -> aseq
# -->
#
def each: () ?{ (Numeric) -> void } -> self
# <!--
# rdoc-file=enumerator.c
# - aseq.exclude_end? -> true or false
# -->
# Returns `true` if this arithmetic sequence excludes its end value.
#
def exclude_end?: () -> bool
# <!--
# rdoc-file=enumerator.c
# - aseq.last -> num or nil
# - aseq.last(n) -> an_array
# -->
# Returns the last number in this arithmetic sequence, or an array of the last
# `n` elements.
#
def last: () -> Numeric?
| (Integer n) -> Array[Numeric]
# <!--
# rdoc-file=enumerator.c
# - aseq.size -> num or nil
# -->
# Returns the number of elements in this arithmetic sequence if it is a finite
# sequence. Otherwise, returns `nil`.
#
def size: () -> (Integer | Float)
# <!--
# rdoc-file=enumerator.c
# - aseq.step -> num
# -->
# Returns the number that defines the common difference between two adjacent
# elements in this arithmetic sequence.
#
def step: () -> Numeric
end