class AxiomusApi::Label

Attributes

address[RW]
b_time[RW]
city[RW]
client_name[RW]
date[RW]
dispatch_number[RW]
e_time[RW]
order_id[RW]
place[RW]
places[RW]
type[RW]
weight[RW]

Public Class Methods

render(labels, template = nil) click to toggle source
# File lib/axiomus_api/label.rb, line 44
def self.render(labels, template = nil)
  renderer = ERB.new(template || default_template)
  labels = labels.is_a?(Array) ? labels : [labels]
  @labels = labels.select{|l| l.is_a?(AxiomusApi::Label)}
  renderer.result(binding)
end

Private Class Methods

default_erb() click to toggle source
# File lib/axiomus_api/label.rb, line 57
def self.default_erb
  File.join(File.dirname(File.expand_path(__FILE__)), 'templates/labels.html.erb')
end
default_template() click to toggle source
# File lib/axiomus_api/label.rb, line 53
def self.default_template
  File.read(default_erb)
end

Public Instance Methods

barcode_base64(height = 70) click to toggle source
# File lib/axiomus_api/label.rb, line 39
def barcode_base64(height = 70)
  s = barcode_raw(height)
  "data:image/png;base64,#{s}"
end
barcode_raw(height = 70) click to toggle source
# File lib/axiomus_api/label.rb, line 33
def barcode_raw(height = 70)
  barcode = Barby::Code39.new("#{dispatch_number}+#{place}")
  barcode.wide_width = 3
  Base64.encode64(barcode.to_png(height: height, margin: 0))
end
delivery_time() click to toggle source
# File lib/axiomus_api/label.rb, line 25
def delivery_time
  if b_time.nil? || e_time.nil?
    nil
  else
    "#{b_time}-#{e_time}"
  end
end
dispatch_number_formatted() click to toggle source
# File lib/axiomus_api/label.rb, line 21
def dispatch_number_formatted
  dispatch_number.to_s.gsub(/(....)$/, '`\1')
end