Class: WallE::Claw

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/wall_e/components/claw.rb

Instance Method Summary collapse

Constructor Details

#initialize(claw_servo, pan_servo) ⇒ Claw

Public: Initialize a Claw

claw_servo - the Servo controlling the claw. pan_servo - the Servo controlling the pan/tilt bracket.



13
14
15
16
# File 'lib/wall_e/components/claw.rb', line 13

def initialize(claw_servo, pan_servo)
  @claw_servo = claw_servo
  @pan_servo = pan_servo
end

Instance Method Details

#closed?Boolean

Public: Indicates if the claw is currently closed.

Returns truthy/falsy value.

Returns:

  • (Boolean)


60
61
62
# File 'lib/wall_e/components/claw.rb', line 60

def closed?
  @claw_servo.maxed?
end

#grabObject

Public: close the claw.

Returns nothing.



28
29
30
# File 'lib/wall_e/components/claw.rb', line 28

def grab
  @claw_servo.max
end

#let_goObject

Public: open the claw.

Returns nothing.



21
22
23
# File 'lib/wall_e/components/claw.rb', line 21

def let_go
  @claw_servo.min
end

#open?Boolean

Public: Indicates if the claw currently open.

Returns truthy/falsy value.

Returns:

  • (Boolean)


53
54
55
# File 'lib/wall_e/components/claw.rb', line 53

def open?
  !closed?
end

#pinch(degrees) ⇒ Object

Public: close the claw.

degrees - the Integer degrees to move the claw to.

Returns nothing.



37
38
39
# File 'lib/wall_e/components/claw.rb', line 37

def pinch(degrees)
  @claw_servo.move_to degrees
end

#tilt(degrees) ⇒ Object

Public: tilt the claw.

degrees - the Integer degrees to tilt the claw.

Returns nothing.



46
47
48
# File 'lib/wall_e/components/claw.rb', line 46

def tilt(degrees)
  @pan_servo.move_to degrees
end