Class: AtPay::Button::QRCode
- Inherits:
-
Object
- Object
- AtPay::Button::QRCode
- Defined in:
- lib/atpay/button/qr_code.rb
Instance Attribute Summary collapse
-
#qr ⇒ Object
readonly
Returns the value of attribute qr.
Instance Method Summary collapse
-
#initialize(button) ⇒ QRCode
constructor
A new instance of QRCode.
- #png(pixels_per_module = 6) ⇒ Object
- #svg ⇒ Object
Constructor Details
#initialize(button) ⇒ QRCode
Returns a new instance of QRCode.
11 12 13 14 |
# File 'lib/atpay/button/qr_code.rb', line 11 def initialize() content = CGI.unescape(.default_mailto) @qr = QREncoder.encode(content, correction: :low) end |
Instance Attribute Details
#qr ⇒ Object (readonly)
Returns the value of attribute qr.
9 10 11 |
# File 'lib/atpay/button/qr_code.rb', line 9 def qr @qr end |
Instance Method Details
#png(pixels_per_module = 6) ⇒ Object
16 17 18 |
# 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 ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# 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 |