class QRencode::QRcode

Overview

The main class for QR symbol generation.

Defined in:

qrencode/qrcode.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(string : String, version = 0, level = ECLevel::MEDIUM, hint = EncodeMode::MODE_8, casesensitive = true, micro = false) #

Creates a new QRcode instance from string.

version is a QR version code. If 0 (the default) is given, then libqrencode chooses the minimum possible version.

level is an ECLevel value, corresponding to the level of error-correction to apply.

hint is an EncodeMode value, corresponding to the encoding used by the QR code.

If casesensitive is set to false, then the data is encoded in all caps (as applies).

If micro is set to true, then a Micro QR code is generated instead (experimental).

Raises EncodeError on any of the following failure conditions:

  • The given string is invalid given hint (EINVAL)
  • Memory allocation fails (ENOMEM)
  • The given string is too large to fit into a QR code (ERANGE)
qr = QRencode::QRcode.new("hello")
# Crystal strings are UTF-8, so this works without `EncodeMode::MODE_KANJI`!
qr2 = QRencode::QRcode.new("こんにちは")

[View source]
def self.new(data : Bytes, version = 0, level = ECLevel::MEDIUM, micro = false) #

Creates a new QRcode instance from data.

Always uses EncodeMode::MODE_8.


[View source]

Instance Method Detail

def data : Bytes #

The actual module (dot) data of the QR symbol. Util contains methods for interacting with these bytes.


[View source]
def each_row(&) #

Yields each row in #data.


[View source]
def finalize #

Destroys the instance's internal state.


[View source]
def version : Int32 #

The version of the QR symbol.


[View source]
def width : Int32 #

The width of the QR symbol.


[View source]