Sha256: e3071ff865ba902d8a0afeb31bc8fc54a88f2fda72c5aefb1b60298f985af945

Contents?: true

Size: 718 Bytes

Versions: 6

Compression:

Stored size: 718 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 
    barcode
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sqed-0.1.5 lib/sqed/parser/barcode_parser.rb
sqed-0.1.4 lib/sqed/parser/barcode_parser.rb
sqed-0.1.3 lib/sqed/parser/barcode_parser.rb
sqed-0.1.2 lib/sqed/parser/barcode_parser.rb
sqed-0.1.1 lib/sqed/parser/barcode_parser.rb
sqed-0.1.0 lib/sqed/parser/barcode_parser.rb