skip down to the 10 comments

rQRCode, a Ruby library for encoding QR Codes

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

We implemented QR Codes on BBC 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 free 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.

You can find out more over at it’s project page on Github:
http://whomwah.github.com/rqrcode/

So that should get you going. Enjoy!

There have been 10 responses to this post.

  1. Bernd Labach

    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

    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

    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

    Duncan,

    thank you, it does work now!

  5. Therese

    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

    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. Carl Jahn

    Hi,

    the Sample:
    #
    require ‘rubygems’
    require ‘rqrcode’

    qr = RQRCode::QRCode.new( ‘my string to generate’, :size => 4, :level => :h )
    puts qr.to_s
    #
    Works fine on the irb, but if i save it in a file an try to execute it with ruby test.rb, i get the error “NameError: uninitialized constant RQRCode”

    Can Anyone hep me?

    Thx Carl from Germany

  8. Duncan

    @Carl, this looks like a path problem, as it works as expected on my machine. What does your hash/bang! line look like. Mine for example is #!/usr/bin/env ruby What is your system setup? and do you have multiple versions of ruby installed on your machine.

  9. kurye

    Whomwah.com ยป rQRCode, a Ruby library for encoding QR Codes great article thankyou
    ..

  10. Samuel

    Hi, I’m trying to find an OCR that allows me to recognize QR codes in Ruby on Rails. I need that users can upload images (paperclip) and parese these images to find QR codes and get the information they contain.
    Can anyone help? thanks!


back to the top