wall_e 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wall_e/components/claw.rb +18 -0
- data/lib/wall_e/version.rb +1 -1
- data/test/claw_test.rb +25 -1
- metadata +1 -1
@@ -29,6 +29,24 @@ module WallE
|
|
29
29
|
@claw_servo.max
|
30
30
|
end
|
31
31
|
|
32
|
+
# Public: close the claw.
|
33
|
+
#
|
34
|
+
# degrees - the Integer degrees to move the claw to.
|
35
|
+
#
|
36
|
+
# Returns nothing.
|
37
|
+
def pinch(degrees)
|
38
|
+
@claw_servo.move_to degrees
|
39
|
+
end
|
40
|
+
|
41
|
+
# Public: tilt the claw.
|
42
|
+
#
|
43
|
+
# degrees - the Integer degrees to tilt the claw.
|
44
|
+
#
|
45
|
+
# Returns nothing.
|
46
|
+
def tilt(degrees)
|
47
|
+
@pan_servo.move_to degrees
|
48
|
+
end
|
49
|
+
|
32
50
|
# Public: Indicates if the claw currently open.
|
33
51
|
#
|
34
52
|
# Returns truthy/falsy value.
|
data/lib/wall_e/version.rb
CHANGED
data/test/claw_test.rb
CHANGED
@@ -29,7 +29,19 @@ class ClawTest < MiniTest::Unit::TestCase
|
|
29
29
|
claw_servo.verify
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def test_pinching
|
33
|
+
claw_servo = MiniTest::Mock.new
|
34
|
+
claw_servo.expect :move_to, 1, [75]
|
35
|
+
pan_servo = DummyServo.new
|
36
|
+
|
37
|
+
claw = WallE::Claw.new(claw_servo, pan_servo)
|
38
|
+
|
39
|
+
claw.pinch 75
|
40
|
+
|
41
|
+
claw_servo.verify
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_tilting_with_words
|
33
45
|
pan_servo = MiniTest::Mock.new
|
34
46
|
pan_servo.expect :min, 1
|
35
47
|
pan_servo.expect :max, 1
|
@@ -44,4 +56,16 @@ class ClawTest < MiniTest::Unit::TestCase
|
|
44
56
|
|
45
57
|
pan_servo.verify
|
46
58
|
end
|
59
|
+
|
60
|
+
def test_tilting
|
61
|
+
pan_servo = MiniTest::Mock.new
|
62
|
+
pan_servo.expect :move_to, 1, [45]
|
63
|
+
claw_servo = DummyServo.new
|
64
|
+
|
65
|
+
claw = WallE::Claw.new(claw_servo, pan_servo)
|
66
|
+
|
67
|
+
claw.tilt 45
|
68
|
+
|
69
|
+
pan_servo.verify
|
70
|
+
end
|
47
71
|
end
|