Class: RapiroWrapper::Command
- Inherits:
-
Object
- Object
- RapiroWrapper::Command
- Defined in:
- lib/rapiro_wrapper/command.rb
Overview
Command class for RAPIRO
Instance Method Summary collapse
-
#initialize(sequences = []) ⇒ Command
constructor
A new instance of Command.
- #to_sequence(duration = 10) ⇒ Object
Constructor Details
#initialize(sequences = []) ⇒ Command
Returns a new instance of Command.
4 5 6 |
# File 'lib/rapiro_wrapper/command.rb', line 4 def initialize(sequences = []) @sequences = sequences end |
Instance Method Details
#to_sequence(duration = 10) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rapiro_wrapper/command.rb', line 8 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 |