PAbarcode gem

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:

[sourcecode language=”shell”]
sudo gem install pabarcode
[/sourcecode]

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

[sourcecode language=”ruby”]
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
[/sourcecode]

Categories:

Leave a Reply