class

QRencode::QRcode

Inherits Reference / Object

The main class for QR symbol generation.

Constructors

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("こんにちは")
Source
new(data : Bytes, version = 0, level = ECLevel::MEDIUM, micro = false)

Creates a new QRcode instance from data.

Always uses EncodeMode::MODE_8.

Source

Instance methods

data

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

Source
each_row

Yields each row in #data.

Source
finalize

Destroys the instance's internal state.

Source
version

The version of the QR symbol.

Source
width

The width of the QR symbol.

Source