The smallest complete rubbs project: a board that asks two questions and says whether each answer is right. Four files, nothing optional. Written against rubbs 1.1.0. For everything beyond the minimum, see Getting started.
quiz-bbs/
├── Gemfile
├── bbs.rb
├── Dockerfile
└── compose.yaml
The gem is called bbs and comes from our Git server, not from rubygems.org. The tag pins a release.
source 'https://rubygems.org'
gem 'bbs', git: 'https://git.teletypegames.org/engines/rubbs.git', tag: 'v1.1.0'
The whole board. ask reads a line into the context under the given name, text writes the block's return value, and when the steps run out the server hangs up.
require 'bbs'
QUESTIONS = {
'What is 2 + 2?' => '4',
'Which year did the C64 come out?' => '1982'
}.freeze
BBS.configure do |c|
c.flow = BBS::Flow.define do
big_banner 'Quiz BBS'
QUESTIONS.each_with_index do |(question, answer), i|
ask :"answer#{i}", prompt: question
text { |ctx| ctx[:"answer#{i}"] == answer ? 'Correct!' : "Wrong, it is #{answer}." }
end
pause 'Bye!', seconds: 2
end
end
BBS.start
git fetches the gem, build-base compiles the sqlite3 native extension that rubbs depends on.
FROM ruby:3.3-alpine
RUN apk add --no-cache git build-base
WORKDIR /app
COPY Gemfile ./
RUN bundle install
COPY bbs.rb ./
EXPOSE 2323
CMD ["bundle", "exec", "ruby", "bbs.rb"]
The board listens on 2323 inside the container; the left side of ports is the port on your machine.
services:
quiz-bbs:
build: .
ports:
- "2323:2323"
restart: unless-stopped
Install Docker: on Windows and macOS Docker Desktop (or OrbStack on macOS), on Linux Docker Engine with the compose plugin. Then, in the project folder:
docker compose up -d --build
Stop it with docker compose down.
Ruby 3.2 or newer, Git and a C compiler are needed.
| OS | Install |
|---|---|
| macOS | xcode-select --install, then brew install ruby |
| Debian / Ubuntu | sudo apt install ruby-full build-essential git |
bundle install
bundle exec ruby bbs.rb
Ctrl-C stops the server. On Windows, use Docker, or run the Linux commands inside WSL.
Any telnet client works; connect to localhost, port 2323.
| OS | Client |
|---|---|
| Windows | Turn on the built-in client once: dism /online /Enable-Feature /FeatureName:TelnetClient (admin prompt), then telnet localhost 2323. Or PuTTY with connection type Telnet. |
| macOS | brew install telnet, then telnet localhost 2323 |
| Linux | sudo apt install telnet, then telnet localhost 2323 |
____ _ ____ ____ _____
/ __ \__ __(_)___ / __ )/ __ ) ___/
/ / / / / / / /_ / / __ / __ \__ \
/ /_/ / /_/ / / / /_ / /_/ / /_/ /__/ /
\___\_\__,_/_/ /___/ /_____/_____/____/
What is 2 + 2?: 4
Correct!
Which year did the C64 come out?: 1984
Wrong, it is 1982.
Bye!