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
Like other ruby gems, add it to your Gemfile or run
> gem install 'grcode'
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"
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:
>> 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"
>> 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"