Sha256: 7a1e75fc162304d40f6bbc177e9a428b7212ce7f53de12c85df11b8b02afcece
Contents?: true
Size: 897 Bytes
Versions: 2
Compression:
Stored size: 897 Bytes
Contents
module QrcodeHelper def qrcode(data = '', options = {}) # Google API: https://google-developers.appspot.com/chart/infographics/docs/qr_codes width = pop_value :width, options, '200' output_encoding = pop_value :output_encoding, options error_correction_level = pop_value :error_correction_level, options margin = pop_value :margin, options qrcode_url = 'https://chart.googleapis.com/chart?cht=qr' qrcode_url += "&chl=#{data}" qrcode_url += "&chs=#{width}x#{width}" qrcode_url += "&choe=#{output_encoding}" unless output_encoding.nil? if error_correction_level.nil? or margin.nil? qrcode_url += "&chld=#{error_correction_level}" unless error_correction_level.nil? qrcode_url += "&chld=|#{margin}" unless margin.nil? else qrcode_url += "&chld=#{error_correction_level}|#{margin}" end image_tag qrcode_url, alt: data end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
andy_rails_toolbox-1.1.1 | app/helpers/qrcode_helper.rb |
andy_rails_toolbox-1.1.0 | app/helpers/qrcode_helper.rb |