A small class for generating and validating Universal Product Codes (UPCs), the 12 digit codes found on many older US products.
¶ ↑
Installationgem install upc
¶ ↑
UsageUPC.new("632737715836").valid? => true UPC.valid?("632737715836") => true UPC.valid?("632737715837") => false UPC.complete("63273771583") => "632737715836" UPC.new("632737715836").to_ean => "0632737715836"
¶ ↑
Further Reader¶ ↑
ContributingSource code is publicly available @ github.com/yob/upc/tree/master. Patches welcome, preferably via a git repo I can pull from.