Class: Array::Seq
Instance Method Summary
collapse
#<=>, #cons, #empty?, #hash, #last, #rest, #to_s, #to_seq
Methods included from Enumerable
#to_list
Constructor Details
#initialize(array, offset = 0) ⇒ Seq
Returns a new instance of Seq.
54
55
56
57
|
# File 'lib/apricot/ruby_ext.rb', line 54
def initialize(array, offset = 0)
@array = array
@offset = offset
end
|
Instance Method Details
75
76
77
|
# File 'lib/apricot/ruby_ext.rb', line 75
def count
@array.length - @offset
end
|
71
72
73
|
# File 'lib/apricot/ruby_ext.rb', line 71
def each
@array[@offset..-1].each {|x| yield x }
end
|
59
60
61
|
# File 'lib/apricot/ruby_ext.rb', line 59
def first
@array[@offset]
end
|
63
64
65
66
67
68
69
|
# File 'lib/apricot/ruby_ext.rb', line 63
def next
if @offset + 1 < @array.length
Seq.new(@array, @offset + 1)
else
nil
end
end
|
79
80
81
|
# File 'lib/apricot/ruby_ext.rb', line 79
def to_a
@array[@offset..-1]
end
|