class MockDfe::Nfe
Public Class Methods
render(version = 'default')
click to toggle source
# File lib/mock_dfe/mock_dfe.rb, line 4 def render(version = 'default') template = render_template(version) generate_xml(template) end
Private Class Methods
generate_xml(template)
click to toggle source
# File lib/mock_dfe/mock_dfe.rb, line 22 def generate_xml(template) @params = JSON.parse(template) xml = File.read("#{File.expand_path("../../", __FILE__)}/mock_dfe/templates/nfe_4.00.xml.erb") load_erb(xml) end
load_erb(template)
click to toggle source
# File lib/mock_dfe/mock_dfe.rb, line 28 def load_erb(template) ERB.new(template).result(binding) end
render_template(version)
click to toggle source
# File lib/mock_dfe/mock_dfe.rb, line 11 def render_template(version) case version when '4.00', 'default' @key_fields = Nfe400.new json_erb = File.read("#{File.expand_path("../../", __FILE__)}/mock_dfe/templates/nfe_4.00.json.erb") else raise "There are no templates for NFe #{version}." end load_erb(json_erb) end