Sha256: 37c6eda7c90bdf3e7799011e1bcc4996e3a16eaacf2431df93b3321bff91dd0d

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

module BrDanfe
  def self.generate(pdf_filename, xml_filename, new_options = {})
    self.options = new_options if !new_options.empty?

    xml_string = File.new(xml_filename)
    render_file(pdf_filename, xml_string)
  end

  def self.render(xml_string, new_options = {})
    self.options = new_options if !new_options.empty?

    pdf = generatePDF(xml_string)
    pdf.render
  end

  def self.render_file(pdf_filename, xml_string, new_options = {})
   self.options = new_options if !new_options.empty?

    pdf = generatePDF(xml_string)
    pdf.render_file pdf_filename
  end

  def self.options
    @options ||= BrDanfe::Options.new
  end

  def self.options=(new_options = {})
    @options = BrDanfe::Options.new(new_options)
  end

  private
  def self.generatePDF(xml_string, new_options = {})
    self.options = new_options if !new_options.empty?

    xml = XML.new(xml_string)

    generator = DanfeGenerator.new(xml)

    pdf = generator.generatePDF
    pdf
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
br_danfe-0.0.1 lib/br_danfe/ruby_danfe.rb