Ruby DSL for invoices

Hi DSL fans,

I’ve been playing around with DSLs recently, inspired by the dynamism
you get for free with Ruby, and thought I’d try writing one.

This is my first effort:

Check out the README.txt for more details. Basically it allows you to
write an invoice in fairly natural language syntax, like this:

new_invoice do
address ‘Test Client, Street, ZIP’
code ‘2006-45’
date ‘3rd Oct’

work_at 50 do
  spent 3.on('Morning meeting')
  spent 0.5.on('Making the coffee for the boss').on('3rd Sept')


And you end up with

It’s work in progress, so suggestions for improvements are welcome.
Feel free to adapt it for your needs, but please send me any
significant patches or new templates so we can spread the love.

Original blog post is here:


[email protected] wrote:

I’ve updated the DSL to support time and currency:

i = new_invoice do
1.pound | 1.5.euros

work_at 20.pounds / hour do
spent 2.hours.on(‘Some work’)
spent 2.days.on(‘More work’) # Note: assumes a day is 8 hours long

print # prints ‘360.00’
print # prints ‘540.00’

Blog post:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs