Double series sequences How can I shorten this class method (currently 10 lines long)?

class DoubleSeries
  def self.generate_sequences(seq1_start, seq2_start, seq1_step, seq2_step, iterations)
    seq1,seq2=seq1_start,seq2_start
    result=[]
    (1..iterations).each do
      result &lt;&lt; seq1 &lt;&lt; seq2
      seq1+=seq1_step
      seq2+=seq2_step
    end 
    result
  end 
end


I tried doing:

class DoubleSeries
  def self.generate_sequences(seq1_start, seq2_start, seq1_step, seq2_step, iterations)
    seq1,seq2=seq1_start,seq2_start
    result=
    (1..iterations).each do
      self &lt;&lt; seq1 &lt;&lt; seq2
      seq1+=seq1_step
      seq2+=seq2_step
    end 
    result
  end 
end


but self is the class at this point (as this is a class method), not the result= variable.
You could a number of different things. For instance, using ranges and a couple of Array methods, I get this:

class DoubleSeries
  def self.generate_sequences(seq1_start, seq2_start, seq1_step, seq2_step, iterations)
    seq1_end = seq1_start + iterations * seq1_step
    seq2_end = seq2_start + iterations * seq2_step
    seq1 = (seq1_start..seq1_end).step(seq1_step)
    seq2 = (seq2_start..seq2_end).step(seq1_step)
    seq1.zip(seq2)
  end
end


There's still some nasty repetition going on. I might suggest simply skipping all this in favor of a generate_sequence method, that only returns a single sequence. Then you can use that plus Array#zip to generate double, triple, or whatever sequences:

def generate_sequence(start, step, iterations)
  limit = start + iterations * step
  (start..limit).step(step).to_a
end

double_seq = generate_sequence(a, b, c).zip(generate_sequence(x, y, z))