Sha256: 75569ae190f8b60fcd16c50c31ea523037ef7a9658d56a1b6889c6b5898ebbac

Contents?: true

Size: 742 Bytes

Versions: 4

Compression:

Stored size: 742 Bytes

Contents

# Given an image, return an ordered array of detectable barcodes



class Sqed::Parser::BarcodeParser < Sqed::Parser

  TYPE = :barcode

  attr_accessor :image

  attr_accessor :barcode

  def initialize(image)
    super
    @image = image
  end

  def barcode
    @barcode ||= get_barcode
    @barcode
  end

  # Uses the same enging as zbarimg that you can install with brew (zbarimg)
  #
  def get_code_128
    ZXing.decode @image.filename
  end

  # try a bunch of options, organized by most common,  give the first hit
  def get_barcode
    [get_code_128].compact.first
  end 

 #def get_datamatrix
 #  https://github.com/srijan/ruby-dmtx
 #end

  # alias to a universal method
  def text(section_type: :default) 
    barcode
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sqed-0.1.9 lib/sqed/parser/barcode_parser.rb
sqed-0.1.8 lib/sqed/parser/barcode_parser.rb
sqed-0.1.7 lib/sqed/parser/barcode_parser.rb
sqed-0.1.6 lib/sqed/parser/barcode_parser.rb