Sha256: 67457f1342725533974b770e9649f703953cfd26a77b8f79c09d1e368e6468b0

Contents?: true

Size: 699 Bytes

Versions: 7

Compression:

Stored size: 699 Bytes

Contents

require 'semacode' #Ruby 1.8: gem install semacode - Ruby 1.9: gem install semacode-ruby19
require 'barby/barcode'

module Barby


  #Uses the semacode library (gem install semacode) to encode DataMatrix barcodes
  class DataMatrix < Barcode2D

    attr_reader :data


    def initialize(data)
      self.data = data
    end


    def data=(data)
      @data = data
      @encoder = nil
    end

    def encoder
      @encoder ||= ::DataMatrix::Encoder.new(data)
    end


    def encoding
      encoder.data.map{|a| a.map{|b| b ? '1' : '0' }.join }
    end


    def semacode?
      #TODO: Not sure if this is right
      data =~ /^http:\/\//
    end


    def to_s
      data
    end


  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
barby-0.6.9 lib/barby/barcode/data_matrix.rb
barby-0.6.8 lib/barby/barcode/data_matrix.rb
barby-0.6.7 lib/barby/barcode/data_matrix.rb
barby-0.6.6 lib/barby/barcode/data_matrix.rb
barby-0.6.5 lib/barby/barcode/data_matrix.rb
barby-0.6.4 lib/barby/barcode/data_matrix.rb
barby-0.6.3 lib/barby/barcode/data_matrix.rb