class AtPay::Button::QRCode

Attributes

qr[R]

Public Class Methods

new(button) click to toggle source
# File lib/atpay/button/qr_code.rb, line 11
def initialize(button)
  content = CGI.unescape(button.default_mailto)
  @qr     = QREncoder.encode(content, correction: :low)
end

Public Instance Methods

png(pixels_per_module=6) click to toggle source
# File lib/atpay/button/qr_code.rb, line 16
def png(pixels_per_module=6)
  @qr.png(pixels_per_module: pixels_per_module).to_blob
end
svg() click to toggle source
# File lib/atpay/button/qr_code.rb, line 20
def svg
  points = @qr.points
  scale  = 10

  Rasem::SVGImage.new(@qr.width * scale, @qr.height * scale) do
    points.each do |point|
      rectangle point[0] * scale, point[1] * scale, scale, scale
    end
  end.output
end