Sha256: c256e2c3568a45aaa7f788ad02de525bfdfbbae478ec8c3331623747c5dd4359

Contents?: true

Size: 785 Bytes

Versions: 1

Compression:

Stored size: 785 Bytes

Contents

require 'ox'
require 'prawn'

require 'br_invoices_pdf/version'
require 'br_invoices_pdf/generator'
require 'br_invoices_pdf/errors/invalid_document_type'

module BrInvoicesPdf
  @generators = {}

  module_function

  def generate(type, xml, options = {})
    generator = @generators[type]
    raise(Errors::InvalidDocumentType, type) unless generator
    generator.generate(xml, options)
  end

  def register(type, renderer, parser)
    raise(ArgumentError, "Expected Symbol or String to type. Received #{type.class}") unless valid_type?(type)
    @generators[type.to_sym] = Generator.new(renderer, parser)
  end

  def supported_document_types
    @generators.keys
  end

  def valid_type?(type)
    type.is_a?(String) || type.is_a?(Symbol)
  end
end

require 'br_invoices_pdf/cfe'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
br_invoices_pdf-0.1.5.alpha.11 lib/br_invoices_pdf.rb