Class: AxiomusApi::Label

Inherits:
Object
  • Object
show all
Defined in:
lib/axiomus_api/label.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#addressObject

Returns the value of attribute address.



17
18
19
# File 'lib/axiomus_api/label.rb', line 17

def address
  @address
end

#b_timeObject

Returns the value of attribute b_time.



13
14
15
# File 'lib/axiomus_api/label.rb', line 13

def b_time
  @b_time
end

#cityObject

Returns the value of attribute city.



19
20
21
# File 'lib/axiomus_api/label.rb', line 19

def city
  @city
end

#client_nameObject

Returns the value of attribute client_name.



10
11
12
# File 'lib/axiomus_api/label.rb', line 10

def client_name
  @client_name
end

#dateObject

Returns the value of attribute date.



12
13
14
# File 'lib/axiomus_api/label.rb', line 12

def date
  @date
end

#dispatch_numberObject

Returns the value of attribute dispatch_number.



8
9
10
# File 'lib/axiomus_api/label.rb', line 8

def dispatch_number
  @dispatch_number
end

#e_timeObject

Returns the value of attribute e_time.



14
15
16
# File 'lib/axiomus_api/label.rb', line 14

def e_time
  @e_time
end

#order_idObject

Returns the value of attribute order_id.



9
10
11
# File 'lib/axiomus_api/label.rb', line 9

def order_id
  @order_id
end

#placeObject

Returns the value of attribute place.



15
16
17
# File 'lib/axiomus_api/label.rb', line 15

def place
  @place
end

#placesObject

Returns the value of attribute places.



16
17
18
# File 'lib/axiomus_api/label.rb', line 16

def places
  @places
end

#typeObject

Returns the value of attribute type.



18
19
20
# File 'lib/axiomus_api/label.rb', line 18

def type
  @type
end

#weightObject

Returns the value of attribute weight.



11
12
13
# File 'lib/axiomus_api/label.rb', line 11

def weight
  @weight
end

Class Method Details

.render(labels, template = nil) ⇒ Object



44
45
46
47
48
49
# 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

Instance Method Details

#barcode_base64(height = 70) ⇒ Object



39
40
41
42
# 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) ⇒ Object



33
34
35
36
37
# 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_timeObject



25
26
27
28
29
30
31
# 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_formattedObject



21
22
23
# File 'lib/axiomus_api/label.rb', line 21

def dispatch_number_formatted
  dispatch_number.to_s.gsub(/(....)$/, '`\1')
end