Class: Phidgets::InterfaceKit::InterfaceKitOutputs
- Inherits:
-
Object
- Object
- Phidgets::InterfaceKit::InterfaceKitOutputs
- Defined in:
- lib/phidgets-ffi/interface_kit.rb
Overview
This class represents an digital output for a PhidgetInterfaceKit. All the properties of an digital output are stored and modified in this class.
Constant Summary collapse
- Klass =
Phidgets::FFI::CPhidgetInterfaceKit
Instance Method Summary collapse
-
#index ⇒ Integer
Returns index of the digital output, or raises an error.
-
#inspect ⇒ Object
Displays data for the digital output.
-
#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 output, or raises an error.
-
#state=(new_state) ⇒ Boolean
Sets the state of the digital output, or raises an error.
Instance Method Details
#index ⇒ Integer
Returns index of the digital output, or raises an error.
166 167 168 |
# File 'lib/phidgets-ffi/interface_kit.rb', line 166 def index @index end |
#inspect ⇒ Object
Displays data for the digital output
161 162 163 |
# File 'lib/phidgets-ffi/interface_kit.rb', line 161 def inspect "#<#{self.class} @index=#{index}, @state=#{state}>" end |
#off ⇒ Boolean Also known as: off?
Returns true if the state is off.
193 194 195 |
# File 'lib/phidgets-ffi/interface_kit.rb', line 193 def off !on end |
#on ⇒ Boolean Also known as: on?
Returns true if the state is true.
187 188 189 |
# File 'lib/phidgets-ffi/interface_kit.rb', line 187 def on state == true end |
#state ⇒ Boolean
Returns state of the digital output, or raises an error.
180 181 182 183 184 |
# File 'lib/phidgets-ffi/interface_kit.rb', line 180 def state ptr = ::FFI::MemoryPointer.new(:int) Klass.getOutputState(@handle, @index, ptr) (ptr.get_int(0) == 0) ? false : true end |
#state=(new_state) ⇒ Boolean
Sets the state of the digital output, or raises an error.
173 174 175 176 177 |
# File 'lib/phidgets-ffi/interface_kit.rb', line 173 def state=(new_state) tmp = new_state ? 1 : 0 Klass.setOutputState(@handle, @index, tmp) new_state end |