Method: Easyzpl::LabelTemplate#initialize
- Defined in:
- lib/easyzpl/label_template.rb
#initialize(name, params = {}) ⇒ LabelTemplate
Called when the new method is invoked
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/easyzpl/label_template.rb', line 15 def initialize(name, params = {}) return if name.nil? return if name.strip.empty? # Set the DPIs self.pdf_dpi = 72 self.printer_dpi = params[:dots] # Set the field orientation self.field_orientation = params[:field_orientation] # Set the number of variable fields self.variable_fields_count = 0 # Create the array that will hold the data self.label_data = [] # Set the default quantity to one self.quantity = 1 # See if invert is set to true self.invert = params[:invert] # The start of the label label_data.push('^XA') label_data.push('^POI') if invert label_data.push('^LT' + Integer(params[:offset] * printer_dpi).to_s) unless params[:offset].nil? label_data.push('^LL' + Integer(params[:height] * printer_dpi).to_s) unless params[:height].nil? label_data.push('^PW' + Integer(params[:width] * printer_dpi).to_s) unless params[:width].nil? label_data.push('^FWB') if field_orientation == :landscape label_data.push('^DF' + name + '^FS') # init_prawn(params) end |