class Range::Seq

Public Class Methods

new(first, last, exclusive) click to toggle source
# File lib/apricot/ruby_ext.rb, line 193
def initialize(first, last, exclusive)
  @first = first
  @last = last
  @exclusive = exclusive
end

Public Instance Methods

each() { |val| ... } click to toggle source
# 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
first() click to toggle source
# File lib/apricot/ruby_ext.rb, line 199
def first
  @first
end
next() click to toggle source
# 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