Build Status Gem Version Coverage Status Code Climate docs


Express logical circuits in code!

How it works

You define components in terms of other component's inputs and outputs. Every "tick" the components compute their next outputs. In between each "tick" the "tock" will update the outputs before the next tick


Add this line to your application's Gemfile:

gem 'circuits'

And then execute:

$ bundle

Or install it yourself as:

$ gem install circuits


Using a component

and_gate =
# Set the inputs
and_gate.inputs[0].set true
and_gate.inputs[1].set false
# Update the AND gate
and_gate.tick # compute the next output from the inputs
and_gate.tock # apply to the output after all components have "ticked"
# Get the output
and_gate.outputs[0].get # false

Linking components

and_gate =
not_gate = [and_gate.outputs[0])


  1. Fork it ( )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Make your changes
  4. Run the tests (bundle exec rake)
  5. Bump the version ( )
  6. Push to the branch (git push origin my-new-feature)
  7. Create a new Pull Request