Class: Escpos::Report

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#barcode, #black, #bold, #center, #cut, #double_height, #double_width, #encode, #encoding, #inverted, #left, #partial_cut, #quad_text, #red, #right, #text, #underline, #underline2

Constructor Details

#initialize(file_or_path, options = {}) ⇒ Report

Returns a new instance of Report.



10
11
12
13
14
15
16
17
18
19
# File 'lib/escpos/report.rb', line 10

def initialize(file_or_path, options = {})
  @options = options
  if file_or_path.is_a?(String)
    @template = ERB.new(File.open(file_or_path).read)
  elsif file_or_path.is_a?(File)
    @template = ERB.new(file_or_path.read)
  else
    raise ArgumentError.new("Must pass instance of file or path as argument.")
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/escpos/report.rb', line 8

def options
  @options
end

Instance Method Details

#renderObject



21
22
23
# File 'lib/escpos/report.rb', line 21

def render
  @template.result binding
end