Home > 2-deed > PAbarcode gem

PAbarcode gem

December 30th, 2009 Petros Leave a comment Go to comments

In a previous post I mentioned that I started maintaining a set of helper Ruby classes for working with barcodes. I have changed the structure of the project to make it a gem and I have published it on GemCutter.

First you need to install the gem:

sudo gem install pabarcode

then the example in the previous post needs to change so as it uses the gem instead of the plain Ruby file:

require "rubygems"
require "pabarcode"

include PAbarcode

file = File.open("apog.txt")

file.each do |line|
  bc = line.slice(0..11)
  bc13 = Barcode.new(bc).get_ean_13
  puts bc13 + line.slice(12..line.length)
end

file.close
Categories: 2-deed Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.