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
15 changed files
with
110 additions
and
142 deletions.
There are no files selected for viewing
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
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
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
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 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'circuits/terminal/output' | ||
|
||
module Circuits | ||
# An input or an output to read from and set | ||
module Terminal | ||
# Reads from a single output | ||
class Input | ||
# Creates the input | ||
# @param opts [Hash] Options to create the Input with | ||
# @option opts [Component::Output] :output The output to read from | ||
def initialize(opts = {}) | ||
@terminal = opts[:terminal] || Output.new(state: opts[:state]) | ||
end | ||
|
||
# Forward get to the output | ||
# @return [Boolean] The state of the output | ||
def get | ||
@terminal.get | ||
end | ||
|
||
# Output to use or state to make a dummy output with | ||
# @param [Output, Boolean] output The output to read from, or state | ||
def set(output) | ||
if [Input, Output].include? output.class | ||
@terminal = output | ||
else | ||
@terminal = Output.new(state: output) | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module Circuits | ||
# An input or an output to read from and set | ||
module Terminal | ||
# Gets set tcked then read | ||
class Output | ||
# Creates the output | ||
# @param opts [Hash] Options to create the Output with | ||
# @option opts [Boolean] :state The initial state of the Output | ||
def initialize(opts = {}) | ||
@next_state = opts[:terminal] || opts[:state] || false | ||
tock | ||
end | ||
|
||
# Gets the state of the terminal | ||
# @return [Boolean] The state of the output | ||
def get | ||
@state | ||
end | ||
|
||
# The next state | ||
# @param [Boolean, Terminal] terminal The terminal or state to output | ||
def set(state) | ||
@next_state = state | ||
end | ||
|
||
# Sets the state what was last set | ||
def tock | ||
if [Input, Output].include? @next_state.class | ||
@state = @next_state.get | ||
else | ||
@state = @next_state | ||
end | ||
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,5 +1,5 @@ | ||
# Circuits allows you to express logical circuits in code | ||
module Circuits | ||
# The version of the Circuits gem | ||
VERSION = '0.6.0' | ||
VERSION = '0.7.0' | ||
end |
This file was deleted.
Oops, something went wrong.