|
Revision 2826, 0.9 kB
(checked in by coji, 6 years ago)
|
|
lang/ruby/ssb: refactor configuration, about:blank URI, cleaned up HTML and remove some trashes.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Id Date Author Rev URL
|
| Line | |
|---|
| 1 | # qrcode.rb - generate QR code data |
|---|
| 2 | # |
|---|
| 3 | # Author:: MIZOGUCHI Coji <mizoguchi.coji at gmail.com> |
|---|
| 4 | # License:: Distribute under the same terms as Ruby |
|---|
| 5 | # |
|---|
| 6 | # $Id$ |
|---|
| 7 | # |
|---|
| 8 | require 'qrcode/qrcode' if FileTest.readable?(File.join(SSB::CONFIG[:vendor_dir], 'qrcode/qrcode.rb')) |
|---|
| 9 | |
|---|
| 10 | class Qrcode |
|---|
| 11 | def initialize |
|---|
| 12 | @path="#{SSB::CONFIG[:vendor_dir]}/qrcode/qrcode_data" |
|---|
| 13 | |
|---|
| 14 | @qrcode_error_correct="L" |
|---|
| 15 | @qrcode_version=0 |
|---|
| 16 | |
|---|
| 17 | @qrcode_structureappend_n=1 |
|---|
| 18 | @qrcode_structureappend_m=1 |
|---|
| 19 | @qrcode_structureappend_parity=0 |
|---|
| 20 | @qrcode_structureappend_originaldata="" |
|---|
| 21 | end |
|---|
| 22 | end |
|---|
| 23 | |
|---|
| 24 | module SSB |
|---|
| 25 | class Qrcode |
|---|
| 26 | def self.make_qrcode(str) |
|---|
| 27 | saved_kcode = $KCODE |
|---|
| 28 | $KCODE = '' |
|---|
| 29 | q = ::Qrcode.new |
|---|
| 30 | begin |
|---|
| 31 | qrcode = '' |
|---|
| 32 | qrcode = q.make_qrcode(str) if q.respond_to?('make_qrcode') |
|---|
| 33 | ensure |
|---|
| 34 | $KCODE = saved_kcode |
|---|
| 35 | return qrcode |
|---|
| 36 | end |
|---|
| 37 | end |
|---|
| 38 | end |
|---|
| 39 | end |
|---|