Class: Escpos::Report
- Inherits:
-
Object
- Object
- Escpos::Report
- Includes:
- ERB::Util, Helpers
- Defined in:
- lib/escpos/report.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(file_or_path, options = {}) ⇒ Report
constructor
A new instance of Report.
- #render ⇒ Object
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 = 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
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/escpos/report.rb', line 8 def @options end |
Instance Method Details
#render ⇒ Object
21 22 23 |
# File 'lib/escpos/report.rb', line 21 def render @template.result binding end |