Class: LabelPrinter::Label::AssetRedirect

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

Overview

rubocop:todo Style/Documentation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ AssetRedirect

Returns a new instance of AssetRedirect.


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

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.


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

def printables
  @printables
end

Instance Method Details

#assetsObject


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

def assets
  printable_assets.each { |asset| asset.barcode! if asset.barcode_number.blank? }
end

#to_hObject


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

def to_h
  case assets.first
  when Plate
    @printer_type_class.double_label? ? AssetPlateDouble.new(assets).to_h : AssetPlate.new(assets).to_h
  when Tube
    AssetTube.new(assets).to_h
  end
end