Class: LabelPrinter::Label::AssetRedirect

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ AssetRedirect

Returns a new instance of AssetRedirect


6
7
8
9
# File 'lib/label_printer/label_printer/label/asset_redirect.rb', line 6

def initialize(options)
  @printables = options[:printables]
  @printer_type_class = options[:printer_type_class]
end

Instance Attribute Details

#printablesObject (readonly)

Returns the value of attribute printables


4
5
6
# File 'lib/label_printer/label_printer/label/asset_redirect.rb', line 4

def printables
  @printables
end

Instance Method Details

#assetsObject


23
24
25
# File 'lib/label_printer/label_printer/label/asset_redirect.rb', line 23

def assets
  printable_assets.each { |asset| asset.barcode! unless asset.barcode_number.present? }
end

#to_hObject


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/label_printer/label_printer/label/asset_redirect.rb', line 11

def to_h
  if assets.first.is_a? Plate
    if @printer_type_class.double_label?
      AssetPlateDouble.new(assets).to_h
    else
      AssetPlate.new(assets).to_h
    end
  elsif assets.first.is_a? Tube
    AssetTube.new(assets).to_h
  end
end