Class: RQRCodeSVG::Image
- Inherits:
-
Object
- Object
- RQRCodeSVG::Image
- Defined in:
- lib/rqrcode_svg/image.rb
Instance Method Summary collapse
-
#initialize(qr_code) ⇒ Image
constructor
A new instance of Image.
- #render(size) ⇒ Object
Constructor Details
#initialize(qr_code) ⇒ Image
Returns a new instance of Image.
4 5 6 7 |
# File 'lib/rqrcode_svg/image.rb', line 4 def initialize(qr_code) @qr_code = qr_code @sequence = Sequence.new(qr_code) end |
Instance Method Details
#render(size) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rqrcode_svg/image.rb', line 9 def render(size) stream = "" block_size = size/@qr_code.module_count.to_f stream += doctype stream += svg_open(size) @sequence.dark_squares_only do |row, column| row_x, row_y = to_coord(size, row), to_coord(size, column) stream += square(row_x, row_y, block_size) end stream += svg_close stream end |