Project

grcode

0.0
No commit activity in last 3 years
No release in over 3 years
Simple wrapper for Google's QRCode generator
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Grcode¶ ↑

Grcode is a plain simple wrapper for generating Qrcode images using Google API

code.google.com/intl/es-ES/apis/chart/infographics/docs/qr_codes.html

Installation¶ ↑

Like other ruby gems, add it to your Gemfile or run

> gem install 'grcode'

How to use it¶ ↑

A piece of code worth 1000 words :)

>> require 'grcode'
=> true
>> qr = Grcode::QRCode.new('Hello world of ruby lovers!')
=> #<Grcode::QRCode:0x100522af0 @url="https://chart.googleapis.com/chart?cht=qr&chl=Hello world of ruby lovers!&chs=150x150">
>> qr.url
=> "https://chart.googleapis.com/chart?cht=qr&chl=Hello world of ruby lovers!&chs=150x150"

Options¶ ↑

Along with the string to encode, you can pass some other options that Google API supports:

  • Size

  • Encoding

  • Correction

  • Margin

Check out the options here: code.google.com/intl/es-ES/apis/chart/infographics/docs/qr_codes.html

Some more examples with the options:

Size¶ ↑

>> qr = Grcode::QRCode.new('Hello world of ruby lovers!', {:size => 300})
=> #<Grcode::QRCode:0x100520138 @url="https://chart.googleapis.com/chart?cht=qr&chl=Hello world of ruby lovers!&chs=300x300">
>> qr.url
=> "https://chart.googleapis.com/chart?cht=qr&chl=Hello world of ruby lovers!&chs=300x300"

Margin¶ ↑

>> qr = Grcode::QRCode.new('Hello world of ruby lovers!', {:size => 300, :margin => 5})
=> #<Grcode::QRCode:0x100513bb8 @url="https://chart.googleapis.com/chart?cht=qr&chld=L|5&chl=Hello world of ruby lovers!&chs=300x300">
>> qr.url
=> "https://chart.googleapis.com/chart?cht=qr&chld=L|5&chl=Hello world of ruby lovers!&chs=300x300"