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:

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s