Class RQRCode::QRCode
In: lib/rqrcode/qrcode/qr_code.rb
Parent: Object

Creation

QRCode objects expect only one required constructor parameter and an optional hash of any other. Here‘s a few examples:

 qr = RQRCode::QRCode.new('hello world')
 qr = RQRCode::QRCode.new('hello world', :size => 1, :level => :m, :mode => :alphanumeric )

Methods

dark?   error_correction_level   is_dark   mode   new   to_s  

Attributes

module_count  [R] 
modules  [R] 
version  [R] 

Public Class methods

Expects a string to be parsed in, other args are optional

  # string - the string you wish to encode
  # size   - the size of the qrcode (default 4)
  # level  - the error correction level, can be:
     * Level :l 7%  of code can be restored
     * Level :m 15% of code can be restored
     * Level :q 25% of code can be restored
     * Level :h 30% of code can be restored (default :h)
  # mode   - the mode of the qrcode (defaults to alphanumeric or byte_8bit, depending on the input data):
     * :number
     * :alphanumeric
     * :byte_8bit
     * :kanji

  qr = RQRCode::QRCode.new('hello world', :size => 1, :level => :m, :mode => :alphanumeric )

Public Instance methods

dark?( row, col )

Alias for is_dark

Return a symbol for current error connection level

is_dark is called with a col and row parameter. This will return true or false based on whether that coordinate exists in the matrix returned. It would normally be called while iterating through modules. A simple example would be:

 instance.is_dark( 10, 10 ) => true

Return a symbol in QRMODE.keys for current mode used

This is a public method that returns the QR Code you have generated as a string. It will not be able to be read in this format by a QR Code reader, but will give you an idea if the final outout. It takes two optional args +:true+ and +:false+ which are there for you to choose how the output looks. Here‘s an example of it‘s use:

 instance.to_s =>
 xxxxxxx x  x x   x x  xx  xxxxxxx
 x     x  xxx  xxxxxx xxx  x     x
 x xxx x  xxxxx x       xx x xxx x

 instance._to_s( :dark => 'E', :light => 'Q') =>
 EEEEEEEQEQQEQEQQQEQEQQEEQQEEEEEEE
 EQQQQQEQQEEEQQEEEEEEQEEEQQEQQQQQE
 EQEEEQEQQEEEEEQEQQQQQQQEEQEQEEEQE

[Validate]