Class: RQRCode::Export::SVG::Rect
- Inherits:
-
BaseOutputSVG
- Object
- BaseOutputSVG
- RQRCode::Export::SVG::Rect
- Defined in:
- lib/rqrcode/export/svg.rb
Instance Attribute Summary
Attributes inherited from BaseOutputSVG
Instance Method Summary collapse
Methods inherited from BaseOutputSVG
Constructor Details
This class inherits a constructor from RQRCode::Export::SVG::BaseOutputSVG
Instance Method Details
#build(module_size, options = {}) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/rqrcode/export/svg.rb', line 92 def build(module_size, = {}) # Extract values from options color = [:color] offset_x = [:offset_x].to_i offset_y = [:offset_y].to_i # Prefix hexadecimal colors unless using a named color (symbol) color = "##{color}" unless color.is_a?(Symbol) @qrcode.modules.each_index do |c| tmp = [] @qrcode.modules.each_index do |r| x = r * module_size + offset_x y = c * module_size + offset_y next unless @qrcode.checked?(c, r) tmp << %(<rect width="#{module_size}" height="#{module_size}" x="#{x}" y="#{y}" fill="#{color}"/>) end @result << tmp.join end end |