Skip to content

Commit

Permalink
edit README
Browse files Browse the repository at this point in the history
  • Loading branch information
i2bskn committed Sep 11, 2013
1 parent 8e46e10 commit 04eb848
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion README.md
Expand Up @@ -22,7 +22,64 @@ Or install it yourself as:

## Usage

TODO: Write usage instructions here
### GTIN13

```ruby
require "jancode"

# Jancode::GTIN13.new("GS1 Company Prefix", "Item Code")
jancode = Jancode::GTIN13.new("456995111", "617")
jancode.check_digit # => 9
jancode.create # => "4569951116179"

# jancode.company_prefix = "456995111"
jancode.item_code = "618"
jancode.create # => "4569951116186"

(1..10).each do |item_code|
jancode.item_code = "%03d" % item_code
puts jancode.create
end
# 4569951110016
# 4569951110023
# 4569951110030
# 4569951110047
# 4569951110054
# 4569951110061
# 4569951110078
# 4569951110085
# 4569951110092
# 4569951110108
```

### GTIN8

```ruby
require "jancode"

# Jancode::GTIN8.new("GS1 Company Prefix", "Item Code")
jancode = Jancode::GTIN8.new("491234", "5")
jancode.check_digit # => 6
jancode.create # => "49123456"

# jancode.company_prefix = "491234"
jancode.item_code = "6"
jancode.create # => "49123463"

(1..9).each do |item_code|
jancode.item_code = item_code.to_s
puts jancode.create
end
# 49123418
# 49123425
# 49123432
# 49123449
# 49123456
# 49123463
# 49123470
# 49123487
# 49123494
```

## Contributing

Expand Down

0 comments on commit 04eb848

Please sign in to comment.