Class: Rupture::ArraySeq
- Inherits:
-
Seq
show all
- Defined in:
- lib/rupture/array_seq.rb
Constant Summary
Constants inherited
from Seq
Seq::Empty
Instance Method Summary
collapse
Methods inherited from Seq
#[], #eql?, #inspect, #to_ary
Methods included from Sequence
#concat, #conj, #count, #divide, #doall, #drop, #drop_last, #drop_while, #each, #empty?, #every?, #filter, #flatten, #foldr, #frequencies, #into, #last, #map, #map_indexed, #mapcat, #next, #not_empty, #nth, #partition, #partition_all, #partition_between, #partition_by, #reduce, #reductions, #remove, #reverse, #second, #separate, #sequential?, #some, #sort, #sort_by, #split_at, #split_with, #take, #take_last, #take_while, #tree_seq
Constructor Details
#initialize(array, index = 0) ⇒ ArraySeq
Returns a new instance of ArraySeq.
3
4
5
6
|
# File 'lib/rupture/array_seq.rb', line 3
def initialize(array, index = 0)
@array = array
@index = index
end
|
Instance Method Details
8
9
10
|
# File 'lib/rupture/array_seq.rb', line 8
def first
@array[@index]
end
|
12
13
14
|
# File 'lib/rupture/array_seq.rb', line 12
def rest
ArraySeq.new(@array, @index.inc)
end
|
16
17
18
|
# File 'lib/rupture/array_seq.rb', line 16
def seq
self if @index < @array.size
end
|
20
21
22
|
# File 'lib/rupture/array_seq.rb', line 20
def size
@array.size - @index
end
|