Sha256: 04343389335350b57d880dfde548369bd1eb293d12fd9ad360f192a51dd52764

Contents?: true

Size: 499 Bytes

Versions: 1

Compression:

Stored size: 499 Bytes

Contents

module RapiroWrapper
  # Command class for RAPIRO
  class Command
    def initialize(sequences = [])
      @sequences = sequences
    end

    def to_sequence(duration = 10)
      targets = RapiroWrapper::ServoMotor.find_servos + [RapiroWrapper::Eyes]
      seq = targets.inject([]) do |ary, servo|
        s = @sequences.find { |item| item.instance_of?(servo) }
        ary << (s ? s : servo.new)
        ary
      end

      format("#P#{seq.map(&:to_code).join}T%03d", duration)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rapiro_wrapper-0.1.0 lib/rapiro_wrapper/command.rb