RQRCodeCore::QRCode
== 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
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}])
Class methods
Instance methods
<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
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
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