Sha256: 810303c0f110d425a9fea99d83b4b0fdfd75ccf60f59048abaf68f480714af12
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
require 'forwardable' module WallE class Claw extend Forwardable def_delegators :@pan_servo, :min, :max, :center # Public: Initialize a Claw # # claw_servo - the Servo controlling the claw. # pan_servo - the Servo controlling the pan/tilt bracket. def initialize(claw_servo, pan_servo) @claw_servo = claw_servo @pan_servo = pan_servo end # Public: open the claw. # # Returns nothing. def let_go @claw_servo.min end # Public: close the claw. # # Returns nothing. def grab @claw_servo.max end # Public: close the claw. # # degrees - the Integer degrees to move the claw to. # # Returns nothing. def pinch(degrees) @claw_servo.move_to degrees end # Public: tilt the claw. # # degrees - the Integer degrees to tilt the claw. # # Returns nothing. def tilt(degrees) @pan_servo.move_to degrees end # Public: Indicates if the claw currently open. # # Returns truthy/falsy value. def open? !closed? end # Public: Indicates if the claw is currently closed. # # Returns truthy/falsy value. def closed? @claw_servo.maxed? end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wall_e-0.1.0 | lib/wall_e/components/claw.rb |
wall_e-0.0.4 | lib/wall_e/components/claw.rb |
wall_e-0.0.3 | lib/wall_e/components/claw.rb |