README.md in turkish_id-0.3.1 vs README.md in turkish_id-0.4.0

- old
+ new

@@ -1,9 +1,11 @@ -# Turkish ID [![Build Status](https://travis-ci.org/krmbzds/turkish_id.svg?branch=master)](https://travis-ci.org/krmbzds/turkish_id) [![Dependency Status](https://gemnasium.com/krmbzds/turkish_id.svg)](https://gemnasium.com/krmbzds/turkish_id) [![Gem](https://img.shields.io/gem/dt/turkish_id.svg)](https://rubygems.org/gems/turkish_id) [![Code Climate](https://codeclimate.com/github/krmbzds/turkish_id/badges/gpa.svg)](https://codeclimate.com/github/krmbzds/turkish_id) [![Test Coverage](https://codeclimate.com/github/krmbzds/turkish_id/badges/coverage.svg)](https://codeclimate.com/github/krmbzds/turkish_id/coverage) -This gem provides methods to validate Turkish Identification Numbers. +# Turkish ID +[![Build Status](https://travis-ci.org/krmbzds/turkish_id.svg?branch=master)](https://travis-ci.org/krmbzds/turkish_id) [![Gem](https://img.shields.io/gem/v/turkish_id.svg)](https://github.com/krmbzds/turkish_id) [![Dependencies](https://img.shields.io/badge/dependencies-none-brightgreen.svg)](https://rubygems.org/gems/turkish_id) [![Gem](https://img.shields.io/gem/dt/turkish_id.svg)](https://rubygems.org/gems/turkish_id) [![Code Climate](https://codeclimate.com/github/krmbzds/turkish_id/badges/gpa.svg)](https://codeclimate.com/github/krmbzds/turkish_id) [![Test Coverage](https://codeclimate.com/github/krmbzds/turkish_id/badges/coverage.svg)](https://codeclimate.com/github/krmbzds/turkish_id/coverage) +This gem provides methods to validate Turkish Identification Numbers. + ## Installation Add this line to your application's Gemfile: ```rb @@ -21,11 +23,11 @@ ## Usage Create a new instance: ```rb -identity_number = TurkishId.new('10000000146') +identity_number = TurkishId.new(10000000146) ``` Use ```is_valid?``` method to check validity: ```rb @@ -51,9 +53,52 @@ 3. ```d11 == (d1 + d2 + d3 + d4 + d5 + d6 + d8 + d9 + d10) mod 10``` Where ```dn``` refers to the ```n-th``` digit of the identification number. Remember that a valid identification number does not imply the existence of an ID. It could only be used as a preliminary check e.g. before querying a government website. This is very similar to credit card validation. + + +## Generating Relatives + +You can generate ID numbers for your younger or elder relatives. + +```rb +me = TurkishId.new(10000000146) +me.elder_relatives.take(5) +``` + +Calling `younger_relative` or `elder_relative` will return an Enumerable class. + +```rb +me.elder_relative +#=> #<Enumerator:0x00007f9e629032d0> +``` + +You can perform standard Enumerable operations on it. + +```rb +me.elder_relative.first + +#=> 10003000082 +``` + +```rb +3.times do + puts me.elder_relative.next() +end + +#=> 10035998982 +#=> 10005999902 +#=> 10008999848 +``` + +```rb +me.elder_relative.take(5) + +#=> [10003000082, 10005999902, 10008999848, 10011999774, 10014999610] +``` + +And so on. ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.