Created
August 23, 2018 01:30
-
-
Save hannelita/1604457050046a9bdc61582ce3d1367b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rqrcode' | |
require 'csv' | |
require 'RMagick' | |
class Attendee | |
attr_reader :email, :register, :full_name, :course, :applied_at, :course_year | |
def initialize(email, register, full_name, course, applied_at, course_year) | |
@email = email | |
@register = register | |
@full_name = full_name | |
@course = course | |
@course_year = course_year | |
@applied_at = applied_at | |
end | |
end | |
attendees = [] | |
CSV.foreach('Agosto_Cadastro_DL.csv', headers: true, header_converters: :symbol) do |row| | |
attendees << Attendee.new(row[:email_address], row[:matricula], row[:nome_completo], | |
row[:curso], row[:timestamp], row[:course_year]) | |
end | |
puts attendees.map(&:email) | |
attendees.each do |attendee| | |
qrcode = RQRCode::QRCode.new("#{attendee.register}\n #{attendee.full_name} \n #{attendee.course}") | |
image = qrcode.as_png(size: 280) | |
IO.write("./dl-aug-qrcodes/#{attendee.register}-qrcode.png", image.to_s) | |
img = Magick::Image.read("./dl-aug-qrcodes/#{attendee.register}-qrcode.png").first | |
my_text = "#{attendee.full_name} \n #{attendee.register} - #{attendee.course}" | |
copyright = Magick::Draw.new | |
copyright.annotate(img, 0, 0, 8, 12, my_text) do | |
self.font = 'Helvetica' | |
self.pointsize = 12 | |
self.font_weight = Magick::BoldWeight | |
self.fill = 'black' | |
end | |
img.write("./dl_aug_qrcodes_badges/#{attendee.register}-qrcode.png") | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment