Class: Easyzpl::LabelTemplate
- Defined in:
- lib/easyzpl/label_template.rb
Overview
This is the label template object This gets uploaded and saved on the printer
Instance Attribute Summary collapse
-
#variable_fields_count ⇒ Object
Returns the value of attribute variable_fields_count.
Attributes inherited from Label
#label_data, #label_height, #label_width, #pdf, #quantity
Instance Method Summary collapse
-
#initialize(name) ⇒ LabelTemplate
constructor
Called when the new method is invoked.
-
#variable_bar_code_39(x, y) ⇒ Object
Sets a variable bar code that can be recalled.
-
#variable_text_field(x, y) ⇒ Object
Sets a variable field that can be recalled.
Methods inherited from Label
#bar_code_39, #change_quantity, #draw_border, #home_position, #text_field, #to_pdf, #to_s
Constructor Details
#initialize(name) ⇒ LabelTemplate
Called when the new method is invoked
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/easyzpl/label_template.rb', line 11 def initialize(name) return if name.nil? return if name.strip.empty? # 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 # The start of the label label_data.push('^XA^DF' + name + '^FS') end |
Instance Attribute Details
#variable_fields_count ⇒ Object
Returns the value of attribute variable_fields_count.
8 9 10 |
# File 'lib/easyzpl/label_template.rb', line 8 def variable_fields_count @variable_fields_count end |
Instance Method Details
#variable_bar_code_39(x, y) ⇒ Object
Sets a variable bar code that can be recalled
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/easyzpl/label_template.rb', line 41 def (x, y) x = 0 unless numeric?(x) y = 0 unless numeric?(y) # update the variable field count self.variable_fields_count += 1 label_data.push('^FO' + x.to_s + ',' + y.to_s + '^B3N,Y,20,N,N^FN' + variable_fields_count.to_s + '^FS') end |
#variable_text_field(x, y) ⇒ Object
Sets a variable field that can be recalled
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/easyzpl/label_template.rb', line 29 def variable_text_field(x, y) x = 0 unless numeric?(x) y = 0 unless numeric?(y) # update the variable field count self.variable_fields_count += 1 label_data.push('^FO' + x.to_s + ',' + y.to_s + '^FN' + variable_fields_count.to_s + '^FS') end |