class

RQRCodeCore::QRCode

Inherits Reference < Object

== Creation

QRCode objects expect only one required constructor parameter and optional named args. Here's a few examples:

qr = RQRCodeCore::QRCode.new("hello world") qr = RQRCodeCore::QRCode.new("hello world", size: 1, level: :m, mode: :alphanumeric)

Constructors

new(data : String | QRSegment | Array(QRSegment) | Array(NamedTuple(data: String, mode: Symbol)) | Array(NamedTuple(data: String, mode: Symbol | Nil)) | Array(NamedTuple(data: String)), level : Symbol | Nil = nil, size : Int32 | Nil = nil, max_size : Int32 | Nil = nil, mode : Symbol | Nil = nil)

Expects a string or array (for multi-segment encoding) to be parsed in, other args are optional

data - the string, QRSegment or array of segments (or named tuples with data:/mode: keys)

size - the size (Int32) of the QR Code (defaults to smallest size needed to encode the data)

max_size - the max_size (Int32) of the QR Code (default RQRCodeCore::QRUtil.max_size)

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 QR Code (defaults to alphanumeric or byte_8bit, depending

on the input data, only used when data is a string):
 * :number
 * :alphanumeric
 * :byte_8bit
 * :kanji

qr = RQRCodeCore::QRCode.new("hello world", size: 1, level: :m, mode: :alphanumeric) segment_qr = RQRCodeCore::QRCode.new(RQRCodeCore::QRSegment.new("foo")) multi_qr = RQRCodeCore::QRCode.new([{data: "foo", mode: :byte_8bit}, {data: "bar1", mode: :alphanumeric}])

Source

Class methods

count_max_data_bits(rs_blocks)
Source
create_bytes(buffer, rs_blocks)
Source
create_data(version, error_correct_level, data_list)
Source

Instance methods

checked?(row, col)

<tt>checked?</tt> 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 <tt>modules</tt>. A simple example would be:

instance.checked?( 10, 10 ) => true

Source
dark?(row, col)

deprecated-алиас dark? из оригинала

Source
error_correction_level

Return a symbol for current error connection level

Source
inspect

Public overide as default inspect is very verbose

RQRCodeCore::QRCode.new("my string to generate", size: 4, level: :h) => QRCodeCore: @data='...', @error_correct_level=2, @version=4, @module_count=33

Source
mode

Return a symbol in QRMODE.keys for current mode used

Source
module_count
Source
modules
Source
multi_segment?

Return true if this QR Code includes multiple encoded segments

Source
to_s(dark : String = "x", light : String = " ", quiet_zone_size : Int32 = 0)

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 three optional args +dark+, +light+ and +quiet_zone_size+ 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

Source
version
Source