Class: Prawn::QRCode::Table::Cell
- Inherits:
-
Table::Cell
- Object
- Table::Cell
- Prawn::QRCode::Table::Cell
- Defined in:
- lib/prawn/qrcode/table/cell.rb
Overview
QRCode is a table cell that renders a QR code inside a table. Most users will create a table via the PDF DSL method make_qr_code_cell.
Constant Summary collapse
- QR_OPTIONS =
%I[content qr_code renderer level mode extent pos dot stroke margin align].freeze
- CELL_OPTS =
%I[padding borders border_widths border_colors border_lines colspan rowspan at].freeze
Instance Method Summary collapse
- #draw_content ⇒ Object
-
#initialize(pdf, pos, **options) ⇒ Cell
constructor
A new instance of Cell.
- #natural_content_height ⇒ Object
- #natural_content_width ⇒ Object
- #qr_code ⇒ Object
- #renderer ⇒ Object
Constructor Details
#initialize(pdf, pos, **options) ⇒ Cell
Returns a new instance of Cell.
15 16 17 18 19 20 |
# File 'lib/prawn/qrcode/table/cell.rb', line 15 def initialize(pdf, pos, **) super(pdf, pos, .select { |k, _| CELL_OPTS.include?(k) }) @margin = 4 @options = .reject { |k, _| CELL_OPTS.include?(k) } @options.each { |k, v| send("#{k}=", v) } end |
Instance Method Details
#draw_content ⇒ Object
30 31 32 |
# File 'lib/prawn/qrcode/table/cell.rb', line 30 def draw_content renderer.render(@pdf) end |
#natural_content_height ⇒ Object
26 27 28 |
# File 'lib/prawn/qrcode/table/cell.rb', line 26 def natural_content_height renderer.extent end |
#natural_content_width ⇒ Object
22 23 24 |
# File 'lib/prawn/qrcode/table/cell.rb', line 22 def natural_content_width renderer.extent end |
#qr_code ⇒ Object
38 39 40 41 |
# File 'lib/prawn/qrcode/table/cell.rb', line 38 def qr_code @qr_code = Prawn::QRCode.min_qrcode(content, **@options) unless defined?(@qr_code) @qr_code end |