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