Class: Circuits::Component::Xnor
- Defined in:
- lib/circuits/component/xnor.rb
Overview
Logical XNOR Operator
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Xnor
constructor
A new instance of Xnor.
-
#tick ⇒ Object
Sets the output to be the result of a logical XNOR of the inputs.
Methods inherited from Base
Constructor Details
#initialize(opts = {}) ⇒ Xnor
Returns a new instance of Xnor.
7 8 9 10 |
# File 'lib/circuits/component/xnor.rb', line 7 def initialize(opts = {}) inputs = opts[:inputs] || 2 super(inputs: inputs, outputs: 1) end |
Instance Method Details
#tick ⇒ Object
Sets the output to be the result of a logical XNOR of the inputs
13 14 15 |
# File 'lib/circuits/component/xnor.rb', line 13 def tick self[:out].set(!inputs.map(&:get).inject(:^)) end |