Class: Phidgets::Encoder::EncoderDigitalInputs

Inherits:
Object
  • Object
show all
Defined in:
lib/phidgets-ffi/encoder.rb

Overview

This class represents a digital input a PhidgetEncoder. All the properties of an digital input are stored and modified in this class.

Constant Summary collapse

Klass =
Phidgets::FFI::CPhidgetEncoder

Instance Method Summary collapse

Instance Method Details

#indexInteger

Returns index of the digital input, or raises an error.

Returns:

  • (Integer)

    returns index of the digital input, or raises an error.



80
81
82
# File 'lib/phidgets-ffi/encoder.rb', line 80

def index 
	@index
end

#inspectObject

Displays data for the digital input



75
76
77
# File 'lib/phidgets-ffi/encoder.rb', line 75

def inspect
  "#<#{self.class} @index=#{index}, @state=#{state}>"
end

#offBoolean Also known as: off?

Returns true if the state is off.

Returns:

  • (Boolean)

    returns true if the state is off.



98
99
100
# File 'lib/phidgets-ffi/encoder.rb', line 98

def off
  !on
end

#onBoolean Also known as: on?

Returns true if the state is true.

Returns:

  • (Boolean)

    returns true if the state is true.



92
93
94
# File 'lib/phidgets-ffi/encoder.rb', line 92

def on
  state == true
end

#stateBoolean

Returns state of the digital input, or raises an error.

Returns:

  • (Boolean)

    returns state of the digital input, or raises an error.



85
86
87
88
89
# File 'lib/phidgets-ffi/encoder.rb', line 85

def state
  ptr = ::FFI::MemoryPointer.new(:int)
  Klass.getInputState(@handle, @index, ptr)
  (ptr.get_int(0) == 0) ? false : true
end