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