Module: Admin::BarcodeHelper
- Included in:
- Spree::Admin::BarcodeController
- Defined in:
- app/helpers/admin/barcode_helper.rb
Instance Method Summary collapse
- #append_barcode_to_pdf_for_variant(variant, pdf = empty_pdf) ⇒ Object
- #current_symbol ⇒ Object
- #empty_pdf(layout = {}) ⇒ Object
- #get_barcode(variant) ⇒ Object
- #product_barcode_url ⇒ Object
Instance Method Details
#append_barcode_to_pdf_for_variant(variant, pdf = empty_pdf) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/helpers/admin/barcode_helper.rb', line 23 def (variant, pdf = empty_pdf) [ variant.name, variant., ( variant.price.to_s + current_symbol ) ].each { |item| pdf.text( item ) } = (variant) pdf.image( StringIO.new( .to_png(:xdim => 5)) , :width => 50.mm , :height => 10.mm, :margin => 2.mm) if pdf.text(' ') pdf end |
#current_symbol ⇒ Object
13 14 15 16 |
# File 'app/helpers/admin/barcode_helper.rb', line 13 def current_symbol @currency = Spree::Config[:currency] @currency == 'NGN' ? 'N' : Money::Currency.table.select { |key, value| value.has_value?(@currency) }.values[0][:symbol] end |
#empty_pdf(layout = {}) ⇒ Object
8 9 10 11 |
# File 'app/helpers/admin/barcode_helper.rb', line 8 def empty_pdf(layout = {}) layout = { :width => 54, :height => 31, :margin => 1 }.merge(layout) pdf = Prawn::Document.new( :page_size => [ layout[:width].mm , layout[:height].mm ] , :margin => layout[:margin].mm ) end |
#get_barcode(variant) ⇒ Object
18 19 20 21 |
# File 'app/helpers/admin/barcode_helper.rb', line 18 def (variant) code = variant.sku return code ? ::Barby::Code128B.new( code ) : code end |
#product_barcode_url ⇒ Object
4 5 6 |
# File 'app/helpers/admin/barcode_helper.rb', line 4 def "/admin/barcode/code/#{@product.id}" end |