Class: Rupture::ArraySeq
- Inherits:
-
Seq
- Object
- Enumerable::Enumerator
- Seq
- Rupture::ArraySeq
show all
- Defined in:
- lib/rupture/array_seq.rb
Instance Method Summary
collapse
Methods inherited from Seq
#==, #[], #each, empty, #to_ary
Methods included from Sequence
#concat, #conj, #count, #doall, #drop, #drop_last, #drop_while, #empty?, #every?, #filter, #flatten, #foldr, #inspect, #into, #last, #map, #mapcat, #next, #not_empty, #nth, #partition, #partition_all, #partition_between, #partition_by, #reduce, #remove, #reverse, #second, #separate, #sequential?, #some, #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
7
|
# File 'lib/rupture/array_seq.rb', line 3
def initialize(array, index = 0)
@array = array
@index = index
super()
end
|
Instance Method Details
#first ⇒ Object
9
10
11
|
# File 'lib/rupture/array_seq.rb', line 9
def first
@array[@index]
end
|
#rest ⇒ Object
13
14
15
|
# File 'lib/rupture/array_seq.rb', line 13
def rest
ArraySeq.new(@array, @index.inc)
end
|
#seq ⇒ Object
17
18
19
|
# File 'lib/rupture/array_seq.rb', line 17
def seq
self if @index < @array.size
end
|
#size ⇒ Object
21
22
23
|
# File 'lib/rupture/array_seq.rb', line 21
def size
@array.size - @index
end
|