Class: Fastlane::QRGenerator
- Inherits:
-
Object
- Object
- Fastlane::QRGenerator
- Defined in:
- lib/fastlane/plugin/polidea/helper/qr_generator.rb
Instance Method Summary collapse
- #generate(path) ⇒ Object
-
#initialize(data, dark_color = ::ChunkyPNG::Color::BLACK) ⇒ QRGenerator
constructor
A new instance of QRGenerator.
Constructor Details
#initialize(data, dark_color = ::ChunkyPNG::Color::BLACK) ⇒ QRGenerator
Returns a new instance of QRGenerator.
5 6 7 8 9 10 11 12 |
# File 'lib/fastlane/plugin/polidea/helper/qr_generator.rb', line 5 def initialize(data, dark_color = ::ChunkyPNG::Color::BLACK) @qr_code = RQRCode::QRCode.new(data, size: 10, level: :m) @dark_color = dark_color @light_color = ::ChunkyPNG::Color::WHITE @margin = 20 @image = ::ChunkyPNG::Image.new(2 * @margin + @qr_code.qrcode.module_count * 5, 2 * @margin + @qr_code.qrcode.module_count * 5, @light_color) end |
Instance Method Details
#generate(path) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fastlane/plugin/polidea/helper/qr_generator.rb', line 14 def generate(path) @qr_code.modules.each_index do |row| @qr_code.modules[row].each_index do |column| if @qr_code.modules[row][column] print_symbol(@dark_color, column, row, (column < 8 && row < 8) || (column < 8 && row >= @qr_code.qrcode.module_count - 8) || (column >= @qr_code.qrcode.module_count - 8 && row < 8)) else print_symbol(@light_color, column, row, (column < 8 && row < 8) || (column < 8 && row >= @qr_code.qrcode.module_count - 8) || (column >= @qr_code.qrcode.module_count - 8 && row < 8)) end end end @image.save(path) end |