Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 67237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:13:42+00:00 2026-05-10T19:13:42+00:00

I’m writing a DSL in Ruby to control an Arduino project I’m working on;

  • 0

I’m writing a DSL in Ruby to control an Arduino project I’m working on; Bardino. It’s a bar monkey that will be software controlled to serve drinks. The Arduino takes commands via the serial port to tell the Arduino what pumps to turn on and for how long.

It currently reads a recipe (see below) and prints it back out. The code for serial communications still need to be worked in as well as some other ideas that I have mentioned below.

This is my first DSL and I’m working off of a previous example so it’s very rough around the edges. Any critiques, code improvements (are there any good references for Ruby DSL best practices or idioms?) or any general comments.

I currently have a rough draft of the DSL so a drink recipe looks like the following (Github link):

desc 'Simple glass of water' recipe 'water' do   ingredients(   'Water' => 2.ounces   ) end 

This in turn is interpreted and currently results with the following (Github link):

[mwilliams@Danzig barduino-tender]$ ruby barduino-tender.rb examples/water.rb Preparing: Simple glass of water  Ingredients:  Water: 2 ounces 

This is a good start for the DSL, however, I do think it could be implemented a little bit better. Some ideas I had below:

  1. Defining what ‘ingredients’ are available using the name of the ingredient and the number pump that it’s connected to. Maybe using a hash? ingredients = {‘water’ => 1, ‘vodka’ => 2}. This way, when an ingredient is interpreted it can either a) send the pump number over the serial port followed by the number of ounces for the Arduino to dispense b) tell the user that ingredient does not exist and abort so nothing is dispensed c) easily have the capability to change or add new ingredients if they’re changed.
  2. Making the recipe look less code like, which is the main purpose of a DSL, maybe build a recipe builder? Using the available ingredients to prompt the user for a drink name, ingredients involved and how much?

The Github project is here, feel free to fork and make pull requests, or post your code suggestions and examples here for other users to see. And if you’re at all curious, the Arduino code, using the Ruby Arduino Development framework is here.

Update

I modified and cleaned things up a bit to reflect Orion Edwards suggestion for a recipe. It now looks like the following.

description 'Screwdriver' do    serve_in 'Highball Glass'   ingredients do     2.ounces :vodka     5.ounces :orange_juice   end end 

I also added a hash (key being the ingredient and the value the pump number it’s hooked up to). I think this provided much progress. I’ll leave the question open for any further suggestions for now, but will ultimately select Orion’s answer. The updated DSL code is here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:13:43+00:00Added an answer on May 10, 2026 at 7:13 pm

    Without looking into implementation details (or your github links), I’d try write a DSL like this:

    (stealing from here: http://supercocktails.com/1310/Long-Island-Iced-Tea-)

    describe 'Long Island Iced Tea' do   serve_in 'Highball Glass'    ingredients do     half.ounce.of :vodka     half.ounce.of :tequila     half.ounce.of :light_rum     half.ounce.of :gin     1.dash.of :coca_cola     #ignoring lemon peel as how can a robot peel a lemon?   end    steps do     add :vodka, :tequila, :light_rum, :gin     stir :gently     add :coca_cola   end end 

    Hope that helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 72k
  • Answers 72k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer As I pointed out in How to implement incremental search… May 11, 2026 at 1:30 pm
  • added an answer I changed the containing form to just construct a new… May 11, 2026 at 1:30 pm
  • added an answer That form of character access is not part of the… May 11, 2026 at 1:30 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.