### Install RQRCode Gem Source: https://github.com/whomwah/rqrcode/blob/main/README.md Instructions for adding the RQRCode gem to your project's Gemfile or installing it manually. ```ruby gem "rqrcode", "~> 3.0" ``` ```ruby gem install rqrcode ``` -------------------------------- ### RQRCodeCore::QRCode Examples Source: https://github.com/whomwah/rqrcode/blob/main/README.md Provides examples of creating QR codes with RQRCodeCore::QRCode using different data types and options. ```ruby simple_qrcode = RQRCodeCore::QRCode.new("https://kyan.com", size: 2, level: :m, mode: :byte_8bit) segment_qrcode = RQRCodeCore::QRCode.new([{ data: "foo", mode: :byte_8bit }]) multi_qrcode = RQRCodeCore::QRCode.new([ { data: 'foo', mode: :byte_8bit }, { data: 'BAR1', mode: :alphanumeric } ]) ``` -------------------------------- ### SVG Rendering Example Source: https://github.com/whomwah/rqrcode/blob/main/README.md Demonstrates how to generate an SVG representation of a QR code using the `as_svg` method with specific options. ```ruby require "rqrcode" qrcode = RQRCode::QRCode.new("http://github.com/") svg = qrcode.as_svg( color: "000", shape_rendering: "crispEdges", module_size: 11, standalone: true, use_path: true ) ``` -------------------------------- ### Basic QR Code Generation Source: https://github.com/whomwah/rqrcode/blob/main/README.md Demonstrates the basic usage of RQRCode to create a QR code object from a string and print its string representation. ```ruby require "rqrcode" qr = RQRCode::QRCode.new("https://kyan.com") puts qr.to_s ``` -------------------------------- ### RQRCodeCore::QRCode Advanced Options Source: https://github.com/whomwah/rqrcode/blob/main/README.md Details the parameters for creating a QR code using RQRCodeCore::QRCode, including data, size, error correction level, and encoding mode. ```APIDOC RQRCodeCore::QRCode.new(data, options) Parameters: data - The string or array of segments to encode. size - The Integer size of the QR Code (defaults to smallest needed). max_size - The maximum Integer size of the QR Code (defaults to RQRCodeCore::QRUtil.max_size). level - The error correction level (:l, :m, :q, :h). Defaults to :h. mode - The encoding mode (:number, :alphanumeric, :byte_8bit). Defaults based on input data. ``` -------------------------------- ### SVG Rendering Options Source: https://github.com/whomwah/rqrcode/blob/main/README.md Lists and explains the available options for rendering a QR code into SVG format, controlling padding, colors, module size, and SVG attributes. ```APIDOC qrcode.as_svg(options) Options: offset - Padding around the QR Code in pixels (default 0). offset_x - X Padding around the QR Code in pixels (default offset). offset_y - Y Padding around the QR Code in pixels (default offset). fill - Background color (e.g. "ffffff", :white, :currentColor) (default none). color - Foreground color (e.g. "000", :black, :currentColor) (default "000"). module_size - The pixel size of each module (defaults 11). shape_rendering - SVG Attribute: auto | optimizeSpeed | crispEdges | geometricPrecision (defaults crispEdges). standalone - Whether to create a full SVG file (default true). use_path - Use for rendering to reduce size (default false). viewbox - Replace width/height with viewBox for CSS scaling (default false). svg_attributes - Hash of custom attributes (default {}). ``` -------------------------------- ### Generate PNG QR Code with ChunkyPNG Source: https://github.com/whomwah/rqrcode/blob/main/README.md Generates a QR code and outputs it as a PNG image using the ChunkyPNG gem. It supports various options for customization like color, size, and border. ```ruby require "rqrcode" qrcode = RQRCode::QRCode.new("http://github.com/") # NOTE: showing with default options specified explicitly png = qrcode.as_png( bit_depth: 1, border_modules: 4, color_mode: ChunkyPNG::COLOR_GRAYSCALE, color: "black", file: nil, fill: "white", module_px_size: 6, resize_exactly_to: false, resize_gte_to: false, size: 120 ) IO.binwrite("/tmp/github-qrcode.png", png.to_s) ``` -------------------------------- ### Generate ANSI QR Code for Terminal Source: https://github.com/whomwah/rqrcode/blob/main/README.md Generates a QR code represented as a string with ANSI color codes, suitable for display in terminals. Customization options include foreground/background colors and fill characters. ```ruby require "rqrcode" qrcode = RQRCode::QRCode.new("http://github.com/") # NOTE: showing with default options specified explicitly svg = qrcode.as_ansi( light: "\033[47m", dark: "\033[40m", fill_character: " ", quiet_zone_size: 4 ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.