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.
173 174 175 |
# File 'lib/phidgets-ffi/rfid.rb', line 173 def index @index end |
#inspect ⇒ Object
Displays data for the digital output
168 169 170 |
# File 'lib/phidgets-ffi/rfid.rb', line 168 def inspect "#<#{self.class} @index=#{index}, @state=#{state}>" end |
#off ⇒ Boolean Also known as: off?
Returns true if the state is off.
200 201 202 |
# File 'lib/phidgets-ffi/rfid.rb', line 200 def off !on end |
#on ⇒ Boolean Also known as: on?
Returns true if the state is true.
194 195 196 |
# File 'lib/phidgets-ffi/rfid.rb', line 194 def on state == true end |
#state ⇒ Boolean
Returns state of the digital output, or raises an error.
187 188 189 190 191 |
# File 'lib/phidgets-ffi/rfid.rb', line 187 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.
180 181 182 183 184 |
# File 'lib/phidgets-ffi/rfid.rb', line 180 def state=(new_state) tmp = new_state ? 1 : 0 Klass.setOutputState(@handle, @index, tmp) new_state end |