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