Class: Phidgets::Stepper::StepperDigitalInputs
- Inherits:
-
Object
- Object
- Phidgets::Stepper::StepperDigitalInputs
- Defined in:
- lib/phidgets-ffi/stepper.rb
Overview
This class represents a digital input for a PhidgetStepper. All the properties of an digital input are stored and modified in this class.
Constant Summary collapse
- Klass =
Phidgets::FFI::CPhidgetStepper
Instance Method Summary collapse
-
#index ⇒ Integer
Returns index of the digital input, or raises an error.
-
#inspect ⇒ Object
Displays data for the digital input.
-
#off ⇒ Boolean
(also: #off?)
Returns true if the state is off.
-
#on ⇒ Boolean
(also: #on?)
Returns true if the state is true.
-
#state ⇒ Boolean
Returns state of the digital input, or raises an error.
Instance Method Details
#index ⇒ Integer
Returns index of the digital input, or raises an error.
116 117 118 |
# File 'lib/phidgets-ffi/stepper.rb', line 116 def index @index end |
#inspect ⇒ Object
Displays data for the digital input
111 112 113 |
# File 'lib/phidgets-ffi/stepper.rb', line 111 def inspect "#<#{self.class} @index=#{index}, @state=#{state}>" end |
#off ⇒ Boolean Also known as: off?
Returns true if the state is off.
134 135 136 |
# File 'lib/phidgets-ffi/stepper.rb', line 134 def off !on end |
#on ⇒ Boolean Also known as: on?
Returns true if the state is true.
128 129 130 |
# File 'lib/phidgets-ffi/stepper.rb', line 128 def on state == true end |
#state ⇒ Boolean
Returns state of the digital input, or raises an error.
121 122 123 124 125 |
# File 'lib/phidgets-ffi/stepper.rb', line 121 def state ptr = ::FFI::MemoryPointer.new(:int) Klass.getInputState(@handle, @index, ptr) (ptr.get_int(0) == 0) ? false : true end |