Class: Rescpos::Report

Inherits:
Object
  • Object
show all
Includes:
ERB::Util, ReportUtil
Defined in:
lib/rescpos/report.rb

Constant Summary

Constants included from ReportUtil

Rescpos::ReportUtil::ALIGN_C, Rescpos::ReportUtil::ALIGN_L, Rescpos::ReportUtil::ALIGN_R, Rescpos::ReportUtil::FONT_BIG, Rescpos::ReportUtil::FONT_NORMAL

Instance Method Summary collapse

Methods included from ReportUtil

#align, #ascii, #chinese, #double_splitline, #fontsize, #grayscale, #horizontal_tab, #key_value, #single_splitline, #table, #text, #underline

Instance Method Details

#render(opts = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/rescpos/report.rb', line 6

def render(opts = {})
  template = opts[:file] ? File.read(opts[:file]) : opts[:template]
  unless template
    template_filename = self.class.to_s.gsub(/Report/, '').underscore
    template = File.read(File.join(Rescpos.configuration.template_path, "#{template_filename}.escpos.erb"))
  end
  erb = ERB.new(template, 0)
  erb.result(binding)
end