rQRCode, a Ruby library for encoding QR Codes

February 24th, 2008 @ 15:37 skip to comments

[Update]
I have also posted a bit more about the upcoming QR Code work for BBC /programmes.

We implemented QR Codes on /programmes (A project I’m one of the Software Engineer’s on, at the BBC) a few weeks back. They’ve been talked about since so I won’t repeat things, only to say it was a simple implementation using a JavaScript library by Kazuhiko Arase and took all of 5 minutes of my lunch hour to add. It started as an email by colleague Michael Smethhurst asking if we could/should implement them, and was also the first I had really heard of them.

Since then, I have done lots more research and think there is great mileage there for promotional material and advertising. At the moment the codes are built on the client side, but this will be moved to the server soon so we can start caching the pages, and also so we can provide the code in a more useful format (maybe images instead of the current HTML table).

So to the point of this post. During my research to understand QR Codes more and because of the lack of readable spec (Anyone know if there is one?) I decided to reverse engineer the JavaScript library into a Ruby Gem as there didn’t seem to be one out there. This helped me understand the how QR Codes are encoded, while at the same time giving something back for other people to use.

Anyway, it’s now done and there is a rQRCode Rubyforge project setup. You can also view the rRQRCode documentation (still to be improved) or just jump straight into installing the gem.

A quick simple example in the console:

Also, here is a quick example of using it in a Ruby on Rails project:

So that should get you going. I’m have some interesting features I working on adding so expect lots of updates over the next few weeks. Enjoy!

Your Responses

  1. Bernd Labach said on 16:11 February 26th, 2008

    Thanks, that was just what I needed. Thumbs for the BBC websites - one of the few major websites that doesn’t suck.

  2. Bernd Labach said on 16:33 February 26th, 2008

    I was a little too quick. I get the follwing error:

    x.each_index do |y|

    undefined method `each_index’ for 0:Fixnum

    to_console works.

  3. Duncan said on 22:50 February 26th, 2008

    Bernd, well spotted, sorry about that, fixed now. I was so concerned in getting the lib out I forgot about the important stuff .. doh!

  4. Bernd Labach said on 12:09 February 27th, 2008

    Duncan,

    thank you, it does work now!

  5. Therese said on 14:25 March 4th, 2008

    Thank you for the post - I’m new at Ruby and I’m just warming up for the Ruby Conference in Copenhagen April 1 :-) .

  6. Matthew Roper said on 16:00 April 1st, 2008

    Many thanks for sharing this!

    I couldn’t see whether the rQRCode libraries were able to produce images directly so I implemented this myself and have posted my code online: Encoding QR Codes using Ruby.

  7. QR Codes on the BBC   published at   Porkandpaws -Shaun Hare » Blog Archive » QR Codes on the BBC said on 21:14 June 3rd, 2008

    […] A friend of mine introduced to to qr codes and blogged about it in his post about qrcodes and said they were going to be a big thing of the future. Being jealous of his Nokia n95 (before I got my Iphone) I dismissed this a bit. Yes they were cool but I did not see them as a great marketing thing until the other day. When I bumped across this article about how the bbc are looking at incorporating qrcodes . So I will have to lool into them more now I think. […]

  8. philwilson.org » Blog Archive » All BBC programmes have a QR code said on 22:33 June 26th, 2008

    […] November 2007 Recent linkageMore fun with QR Codes and the BBC logoembedding images inside QR codesWhomwah.com » Blog Archive » rQRCode, a Ruby library for encoding QR Codesthe BBC provide qr codes for all their programmes. will blog about this. definitely check out all the links!A Quick Code Igniter and JQuery Ajax Tutorialtadaweb2py Enterprise Web FrameworkI like the look of this. Been doing some turbogears/django comparisons recently.Care-o-meter « Lolcats ?n? Funny Pictures of Cats - I Can Has Cheezburger?me, according to a workmateGTA 4 Liberty City Mapusing google maps and the yui toolset. excellent work, very effective.MOO Business Cards « YO, CEOvery nice. must order now. thanks for the pointer to nicky_jLeah Culver » Tiny URLs based on pkthat’ll workrobotframework - Google Code"Robot Framework is a Python-based keyword-driven test automation framework for acceptance level testing " looks like FIT?We’re all ops people nowso what are the ops people supposed to do? just go away, hopefully […]

Leave a comment :

Please keep it polite and on topic. Show who you are with a Gravatar. Your email address is required, but won't be displayed or passed on ( that's a promise! )

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>