lib/scissor/sequence.rb in youpy-scissor-0.0.19 vs lib/scissor/sequence.rb in youpy-scissor-0.0.20
- old
+ new
@@ -4,30 +4,27 @@
@pattern = pattern
@duration_per_step = duration_per_step
end
def apply(instruments)
- result = Scissor()
-
- @pattern.split(//).each do |c|
+ @pattern.split(//).inject(Scissor()) do |result, c|
if instruments.include?(c.to_sym)
instrument = instruments[c.to_sym]
if instrument.is_a?(Proc)
instrument = instrument.call(c)
end
if @duration_per_step > instrument.duration
- result += instrument
- result += Scissor.silence(@duration_per_step - instrument.duration)
+ result += instrument + Scissor.silence(@duration_per_step - instrument.duration)
else
result += instrument.slice(0, @duration_per_step)
end
else
result += Scissor.silence(@duration_per_step)
end
- end
- result
+ result
+ end
end
end
end