File: README.md

package info (click to toggle)
ruby-rqrcode 0.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 252 kB
  • sloc: ruby: 987; makefile: 2
file content (119 lines) | stat: -rw-r--r-- 2,720 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# rQRCode, Encode QRCodes

## Overview

rQRCode is a library for encoding QR Codes in Ruby. It has a simple interface with all the standard qrcode options. It was adapted from the Javascript library by Kazuhiko Arase.

Let's clear up some rQRCode stuff.

* rQRCode is a __standalone library__ It requires no other libraries. Just Ruby!
* It is an encoding library. You can't decode QR codes with it.
* The interface is simple and assumes you just want to encode a string into a QR code
* QR code is trademarked by Denso Wave inc

## Resources

* wikipedia:: http://en.wikipedia.org/wiki/QR_Code
* Denso-Wave website:: http://www.denso-wave.com/qrcode/index-e.html
* kaywa:: http://qrcode.kaywa.com

## Installing

You may get the latest stable version from Rubygems. 

    gem install rqrcode

You can also get the latest source from http://github.com/whomwah/rqrcode

    git clone git://github.com/whomwah/rqrcode.git

## Tests

To run the tests:

    $ rake
 
## Loading rQRCode Itself

You have installed the gem already, yeah?

    require 'rubygems'
    require 'rqrcode'

## Simple QRCode generation to screen

```ruby
qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )
puts qr.to_s
#
# Prints:
# xxxxxxx x  x x   x x  xx  xxxxxxx
# x     x  xxx  xxxxxx xxx  x     x
# x xxx x  xxxxx x       xx x xxx x
# ... etc
```

## Simple QRCode generation to template (RubyOnRails)

```erb
# Controller
@qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )

# View: (minimal styling added)
<style type="text/css">
table {
  border-width: 0;
  border-style: none;
  border-color: #0000ff;
  border-collapse: collapse;
}
td {
  border-width: 0; 
  border-style: none;
  border-color: #0000ff; 
  border-collapse: collapse; 
  padding: 0; 
  margin: 0; 
  width: 10px; 
  height: 10px; 
}
td.black { background-color: #000; }
td.white { background-color: #fff; }
</style>

<table>
<% @qr.modules.each_index do |x| %>
  <tr>  
  <% @qr.modules.each_index do |y| %>
   <% if @qr.dark?(x,y) %>
    <td class="black"/>
   <% else %>
    <td class="white"/>
   <% end %>
  <% end %>
  </tr>
<% end %>
</table>
```

## Authors

Original author: Duncan Robertson

Special thanks to the following people for submitting patches:

* [Gioele Barabucci](https://github.com/gioele) 
* [Rob la Lau](https://github.com/ohreally)
* [Chris Mowforth](http://blog.99th.st)
* [Tore Darell](http://tore.darell.no)
* [Daniel Schierbeck](https://github.com/dasch)
* Vladislav Gorodetskiy

## Contributing
* Fork the project
* Send a pull request
* Don't touch the .gemspec, I'll do that when I release a new version

## Copyright

MIT Licence (http://www.opensource.org/licenses/mit-license.html)