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
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/rqrcode/export/svg.rb', line 169 def build(module_size, = {}) # Extract values from options color = [:color] offset_x = [:offset_x].to_i offset_y = [:offset_y].to_i @qrcode.modules.each_index do |c| @qrcode.modules.each_index do |r| next unless @qrcode.checked?(c, r) x = r * module_size + offset_x y = c * module_size + offset_y @result << %(<rect width="#{module_size}" height="#{module_size}" x="#{x}" y="#{y}" fill="#{color}"/>) end end end |