2018-10-22 11:23:17 -04:00
|
|
|
# Series class
|
2018-09-20 16:45:20 -04:00
|
|
|
class Series
|
|
|
|
def initialize(digits)
|
|
|
|
@digits = digits
|
|
|
|
end
|
|
|
|
|
|
|
|
def slices(slice_length)
|
2018-10-22 11:23:17 -04:00
|
|
|
raise ArgumentError if slice_length > @digits.length
|
2018-09-20 16:45:20 -04:00
|
|
|
|
|
|
|
slices = []
|
|
|
|
0.upto(@digits.length - slice_length) do |i|
|
|
|
|
slices.push @digits.slice(i, slice_length)
|
|
|
|
end
|
|
|
|
slices
|
|
|
|
end
|
|
|
|
end
|