Class: Range::Seq
Instance Method Summary
collapse
#<=>, #cons, #empty?, #hash, #last, #rest, #to_s, #to_seq
Methods included from Enumerable
#to_list
Constructor Details
#initialize(first, last, exclusive) ⇒ Seq
193
194
195
196
197
|
# File 'lib/apricot/ruby_ext.rb', line 193
def initialize(first, last, exclusive)
@first = first
@last = last
@exclusive = exclusive
end
|
Instance Method Details
213
214
215
216
217
218
219
220
221
222
223
224
|
# File 'lib/apricot/ruby_ext.rb', line 213
def each
prev = nil
val = @first
until prev == @last || (val == @last && @exclusive)
yield val
prev = val
val = val.succ
end
self
end
|
199
200
201
|
# File 'lib/apricot/ruby_ext.rb', line 199
def first
@first
end
|
203
204
205
206
207
208
209
210
211
|
# File 'lib/apricot/ruby_ext.rb', line 203
def next
next_val = @first.succ
if @first == @last || (next_val == @last && @exclusive)
nil
else
Seq.new(next_val, @last, @exclusive)
end
end
|