Class: Rupture::ArraySeq

Inherits:
Seq
  • Object
show all
Defined in:
lib/rupture/array_seq.rb

Direct Known Subclasses

RArraySeq

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

#firstObject



9
10
11
# File 'lib/rupture/array_seq.rb', line 9

def first
  @array[@index]
end

#restObject



13
14
15
# File 'lib/rupture/array_seq.rb', line 13

def rest
  ArraySeq.new(@array, @index.inc)
end

#seqObject



17
18
19
# File 'lib/rupture/array_seq.rb', line 17

def seq
  self if @index < @array.size
end

#sizeObject



21
22
23
# File 'lib/rupture/array_seq.rb', line 21

def size
  @array.size - @index
end