Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
70 additions
and
316 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
require 'circuits/component' | ||
require 'circuits/component/base' | ||
|
||
module Circuits | ||
module Component | ||
# Logical AND Operator | ||
class And | ||
include Component | ||
class And < Base | ||
def initialize(opts = {}) | ||
@input_count = 2 | ||
@output_count = 1 | ||
super opts | ||
end | ||
|
||
# Sets the output to be the result of a logical AND of the inputs | ||
def tick | ||
outputs[0].set(inputs.map(&:get).inject(:&)) | ||
end | ||
|
||
private | ||
|
||
def set_defaults | ||
@input_count = 2 | ||
@output_count = 1 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
require 'circuits/component' | ||
require 'circuits/component/base' | ||
|
||
module Circuits | ||
module Component | ||
# Logical NAND Operator | ||
class Nand | ||
include Component | ||
class Nand < Base | ||
def initialize(opts = {}) | ||
@input_count = 2 | ||
@output_count = 1 | ||
super opts | ||
end | ||
|
||
# Sets the output to be the result of a logical NAND of the inputs | ||
def tick | ||
outputs[0].set(!inputs.map(&:get).inject(:&)) | ||
end | ||
|
||
private | ||
|
||
def set_defaults | ||
@input_count = 2 | ||
@output_count = 1 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
require 'circuits/component' | ||
require 'circuits/component/base' | ||
|
||
module Circuits | ||
module Component | ||
# Logical NOR Operator | ||
class Nor | ||
include Component | ||
class Nor < Base | ||
def initialize(opts = {}) | ||
@input_count = 2 | ||
@output_count = 1 | ||
super opts | ||
end | ||
|
||
# Sets the output to be the result of a logical OR of the inputs | ||
def tick | ||
outputs[0].set(!inputs.map(&:get).inject(:|)) | ||
end | ||
|
||
private | ||
|
||
def set_defaults | ||
@input_count = 2 | ||
@output_count = 1 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
require 'circuits/component' | ||
require 'circuits/component/base' | ||
|
||
module Circuits | ||
module Component | ||
# Logical NOT Operator | ||
class Not | ||
include Component | ||
class Not < Base | ||
def initialize(opts = {}) | ||
@input_count = 1 | ||
@output_count = 1 | ||
super opts | ||
end | ||
|
||
# Sets the output to be the result of a logical NOT of the inputs | ||
def tick | ||
outputs[0].set(!inputs[0].get) | ||
end | ||
|
||
private | ||
|
||
def set_defaults | ||
@input_count = 1 | ||
@output_count = 1 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
require 'circuits/component' | ||
require 'circuits/component/base' | ||
|
||
module Circuits | ||
module Component | ||
# Logical OR Operator | ||
class Or | ||
include Component | ||
class Or < Base | ||
def initialize(opts = {}) | ||
@input_count = 2 | ||
@output_count = 1 | ||
super opts | ||
end | ||
|
||
# Sets the output to be the result of a logical OR of the inputs | ||
def tick | ||
outputs[0].set(inputs.map(&:get).inject(:|)) | ||
end | ||
|
||
private | ||
|
||
def set_defaults | ||
@input_count = 2 | ||
@output_count = 1 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
require 'circuits/component' | ||
require 'circuits/component/base' | ||
|
||
module Circuits | ||
module Component | ||
# Logical XNOR Operator | ||
class Xnor | ||
include Component | ||
class Xnor < Base | ||
def initialize(opts = {}) | ||
@input_count = 2 | ||
@output_count = 1 | ||
super opts | ||
end | ||
|
||
# Sets the output to be the result of a logical XNOR of the inputs | ||
def tick | ||
outputs[0].set(!inputs.map(&:get).inject(:^)) | ||
end | ||
|
||
private | ||
|
||
def set_defaults | ||
@input_count = 2 | ||
@output_count = 1 | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
require 'circuits/component' | ||
require 'circuits/component/base' | ||
|
||
module Circuits | ||
module Component | ||
# Logical XOR Operator | ||
class Xor | ||
include Component | ||
class Xor < Base | ||
def initialize(opts = {}) | ||
@input_count = 2 | ||
@output_count = 1 | ||
super opts | ||
end | ||
|
||
# Sets the output to be the result of a logical XOR of the inputs | ||
def tick | ||
outputs[0].set(inputs.map(&:get).inject(:^)) | ||
end | ||
|
||
private | ||
|
||
def set_defaults | ||
@input_count = 2 | ||
@output_count = 1 | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.