Class: Phidgets::Encoder::EncoderEncoders
- Inherits:
-
Object
- Object
- Phidgets::Encoder::EncoderEncoders
- Defined in:
- lib/phidgets-ffi/encoder.rb
Overview
This class represents a encoder for a PhidgetEncoder. All the properties of an encoder are stored and modified in this class.
Constant Summary collapse
- Klass =
Phidgets::FFI::CPhidgetEncoder
Instance Method Summary collapse
-
#enabled ⇒ Boolean
Returns the enabled state of a encoder, or raises an error.
-
#enabled=(new_state) ⇒ Boolean
Sets the enabled state of an encoder, or raises an error.
-
#index ⇒ Integer
Returns the index of the encoder, or raises an error.
-
#index_position ⇒ Integer
Returns the index position for an encoder that supports index, or raises an error.
-
#inspect ⇒ Object
Displays data for the encoder.
-
#position ⇒ Integer
Returns the position of an encoder, or raises an error.
-
#position=(new_position) ⇒ Integer
Sets the position of an encoder, or raises an error.
Instance Method Details
#enabled ⇒ Boolean
Returns the enabled state of a encoder, or raises an error.
133 134 135 136 137 |
# File 'lib/phidgets-ffi/encoder.rb', line 133 def enabled ptr = ::FFI::MemoryPointer.new(:int) Klass.getEnabled(@handle, @index, ptr) (ptr.get_int(0) == 0) ? false : true end |
#enabled=(new_state) ⇒ Boolean
Sets the enabled state of an encoder, or raises an error.
142 143 144 145 146 |
# File 'lib/phidgets-ffi/encoder.rb', line 142 def enabled=(new_state) tmp = new_state ? 1 : 0 Klass.setEnabled(@handle, @index, tmp) new_state end |
#index ⇒ Integer
Returns the index of the encoder, or raises an error.
121 122 123 |
# File 'lib/phidgets-ffi/encoder.rb', line 121 def index @index end |
#index_position ⇒ Integer
Returns the index position for an encoder that supports index, or raises an error.
126 127 128 129 130 |
# File 'lib/phidgets-ffi/encoder.rb', line 126 def index_position ptr = ::FFI::MemoryPointer.new(:int) Klass.getIndexPosition(@handle, @index, ptr) ptr.get_int(0) end |
#inspect ⇒ Object
Displays data for the encoder.
115 116 117 118 |
# File 'lib/phidgets-ffi/encoder.rb', line 115 def inspect "#<#{self.class} @index=#{index}, @position=#{position}>" end |
#position ⇒ Integer
Returns the position of an encoder, or raises an error.
149 150 151 152 153 |
# File 'lib/phidgets-ffi/encoder.rb', line 149 def position ptr = ::FFI::MemoryPointer.new(:int) Klass.getPosition(@handle, @index, ptr) ptr.get_int(0) end |
#position=(new_position) ⇒ Integer
Sets the position of an encoder, or raises an error.
158 159 160 161 |
# File 'lib/phidgets-ffi/encoder.rb', line 158 def position=(new_position) Klass.setPosition(@handle, @index, new_position.to_i) new_position end |