Skip to content

eltercero/grcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"

About

Simple wrapper to get QRCode from Google API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages