Class: QrForge::Exporter

Inherits:
Object
  • Object
show all
Defined in:
lib/qr_forge/exporter.rb

Overview

Handles exporting the generated QR code in various formats.

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ Exporter

Returns a new instance of Exporter.



7
8
9
# File 'lib/qr_forge/exporter.rb', line 7

def initialize(config:)
  @format = config.dig(:output, :format) || :svg
end

Instance Method Details

#export(svg) ⇒ String

Exports the generated QR code in the specified format.

Parameters:

  • svg (String)

    The generated SVG content of the QR code

Returns:

  • (String)

    The exported QR code in the specified format

Raises:

  • (RuntimeError)

    if the format is unsupported



16
17
18
19
20
21
22
23
# File 'lib/qr_forge/exporter.rb', line 16

def export(svg)
  case @format
  when :svg
    process_svg(svg)
  else
    raise "Unsupported export format: #{@format}"
  end
end