Class: Easyzpl::StoredLabel
Overview
This is the stored label object
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
-
#add_field(value) ⇒ Object
Adds a variable that is to be applied to the saved template.
-
#initialize(name) ⇒ StoredLabel
constructor
Called when the new method is invoked.
Methods inherited from Label
#bar_code_39, #change_quantity, #draw_border, #home_position, #text_field, #to_pdf, #to_s
Constructor Details
#initialize(name) ⇒ StoredLabel
Called when the new method is invoked
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/easyzpl/stored_label.rb', line 10 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^XF' + name + '^FS') end |
Instance Attribute Details
#variable_fields_count ⇒ Object
Returns the value of attribute variable_fields_count.
7 8 9 |
# File 'lib/easyzpl/stored_label.rb', line 7 def variable_fields_count @variable_fields_count end |
Instance Method Details
#add_field(value) ⇒ Object
Adds a variable that is to be applied to the saved template
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/easyzpl/stored_label.rb', line 28 def add_field(value) return if value.nil? return if value.strip.empty? # Increment the variable field count self.variable_fields_count += 1 # Add the field label_data.push('^FN' + variable_fields_count.to_s + '^FD' + value + '^FS') end |