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