class Fastlane::QRGenerator

Public Class Methods

new(data, dark_color = ::ChunkyPNG::Color::BLACK) click to toggle source
# 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

Public Instance Methods

generate(path) click to toggle source
# 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

Private Instance Methods

print_symbol(color, column, row, interpolate) click to toggle source
print_symbol_row(color, column, row, interpolate) click to toggle source