class QRencode::QRcode
- QRencode::QRcode
- Reference
- Object
Overview
The main class for QR symbol generation.
Defined in:
qrencode/qrcode.crConstructors
-
.new(string : String, version = 0, level = ECLevel::MEDIUM, hint = EncodeMode::MODE_8, casesensitive = true, micro = false)
Creates a new
QRcode
instance from string. -
.new(data : Bytes, version = 0, level = ECLevel::MEDIUM, micro = false)
Creates a new
QRcode
instance from data.
Instance Method Summary
-
#data : Bytes
The actual module (dot) data of the QR symbol.
-
#each_row(&)
Yields each row in
#data
. -
#finalize
Destroys the instance's internal state.
-
#version : Int32
The version of the QR symbol.
-
#width : Int32
The width of the QR symbol.
Constructor Detail
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("こんにちは")
Creates a new QRcode
instance from data.
Always uses EncodeMode::MODE_8
.