Sample code for 30+ languages & platforms
Ruby Requires Chilkat v11.7.0+

Get the QR Code Capabilities of the Chilkat Version in Use

See more QR Code Examples

Demonstrates the capabilities operation, which describes what the installed version of Chilkat can do: the range of QR versions, the error-correction levels, the operations, the image formats and the limits. A program can check for a feature here instead of testing for a Chilkat version number. The request can be an empty JSON object.

Chilkat Ruby Downloads

Ruby
require 'chilkat'

success = false

#  This example requires the Chilkat API to have been previously unlocked.
#  See Global Unlock Sample for sample code.

json = Chilkat::CkJsonObject.new()
fmt = Chilkat::CkFormats.new()
jsonOut = Chilkat::CkJsonObject.new()
success = fmt.QrCode("capabilities",json,jsonOut)
if (success == false)
    print fmt.lastErrorText() + "\n";
    exit
end

print "Chilkat version: " + jsonOut.stringOf("productVersion") + "\n";
print "symbology: " + jsonOut.stringOf("symbologies[0].id") + "\n";
print "QR versions: " + jsonOut.IntOf("symbologies[0].encoding.version.min").to_s() + " to " + jsonOut.IntOf("symbologies[0].encoding.version.max").to_s() + "\n";
print "structured append, most symbols: " + jsonOut.IntOf("symbologies[0].structuredAppend.maxSymbols").to_s() + "\n";

n = jsonOut.SizeOfArray("symbologies[0].encoding.errorCorrection")
for i in 0 .. n - 1
    jsonOut.put_I(i)
    print "error correction: " + jsonOut.stringOf("symbologies[0].encoding.errorCorrection[i]") + "\n";
end

#  The operations this version implements.
n = jsonOut.SizeOfArray("operations")
for i in 0 .. n - 1
    jsonOut.put_I(i)
    if (jsonOut.BoolOf("operations[i].available") == true)
        print "operation: " + jsonOut.stringOf("operations[i].name") + "\n";
    end

end

n = jsonOut.SizeOfArray("imageFormats.output")
for i in 0 .. n - 1
    jsonOut.put_I(i)
    print "image format: " + jsonOut.stringOf("imageFormats.output[i]") + "\n";
end

print "default timeout: " + jsonOut.IntOf("limits.timeoutMs.default").to_s() + " ms" + "\n";
print "default largest image: " + jsonOut.IntOf("limits.maxPixels.default").to_s() + " pixels" + "\n";

#  Sample output:

#  Chilkat version: 11.7.0
#  symbology: qr
#  QR versions: 1 to 40
#  structured append, most symbols: 16
#  error correction: auto
#  error correction: L
#  error correction: M
#  error correction: Q
#  error correction: H
#  operation: generate
#  operation: measure
#  operation: validate
#  operation: capabilities
#  image format: png
#  image format: svg
#  default timeout: 10000 ms
#  default largest image: 16777216 pixels