Sha256: 4924b505a61933f73c5a9dcfb0bc185773a8193e68fba4a4a95bf7173dc1d77f

Contents?: true

Size: 704 Bytes

Versions: 2

Compression:

Stored size: 704 Bytes

Contents

module Scissor
  class Sequence
    def initialize(pattern, duration_per_step)
      @pattern = pattern
      @duration_per_step = duration_per_step
    end

    def apply(scissors)
      result = Scissor()

      @pattern.split(//).each do |c|
        if scissors.include?(c.to_sym)
          scissor = scissors[c.to_sym]

          if @duration_per_step > scissor.duration
            result += scissor
            result += Scissor.silence(@duration_per_step - scissor.duration)
          else
            result += scissors[c.to_sym].slice(0, @duration_per_step)
          end
        else
          result += Scissor.silence(@duration_per_step)
        end
      end

      result
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
youpy-scissor-0.0.15 lib/scissor/sequence.rb
youpy-scissor-0.0.16 lib/scissor/sequence.rb