Class: Phidgets::RFID::RFIDOutputs
- Inherits:
-
Object
- Object
- Phidgets::RFID::RFIDOutputs
- Defined in:
- lib/phidgets-ffi/rfid.rb
Overview
This class represents an digital output for a PhidgetRFID All the properties of an digital output are stored and modified in this class.
Constant Summary collapse
- Klass =
Phidgets::FFI::CPhidgetRFID
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.
151 152 153 |
# File 'lib/phidgets-ffi/rfid.rb', line 151 def index @index end |
#inspect ⇒ Object
Displays data for the digital output
146 147 148 |
# File 'lib/phidgets-ffi/rfid.rb', line 146 def inspect "#<#{self.class} @index=#{index}, @state=#{state}>" end |
#off ⇒ Boolean Also known as: off?
Returns true if the state is off.
178 179 180 |
# File 'lib/phidgets-ffi/rfid.rb', line 178 def off !on end |
#on ⇒ Boolean Also known as: on?
Returns true if the state is true.
172 173 174 |
# File 'lib/phidgets-ffi/rfid.rb', line 172 def on state == true end |
#state ⇒ Boolean
Returns state of the digital output, or raises an error.
165 166 167 168 169 |
# File 'lib/phidgets-ffi/rfid.rb', line 165 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.
158 159 160 161 162 |
# File 'lib/phidgets-ffi/rfid.rb', line 158 def state=(new_state) tmp = new_state ? 1 : 0 Klass.setOutputState(@handle, @index, tmp) new_state end |