GithubHelp home page GithubHelp logo

egn's Introduction

Build Status Coverage Status Code Climate

Egn

EGN(ЕГН) is the national identification number of Bulgarian citizens. This gem provides ways to generate, validate and parse any given valid number for information.

Installation

Add this line to your application's Gemfile:

gem 'egn'

And then execute:

$ bundle

Or install it yourself as:

$ gem install egn

Usage

require 'egn'

# Quickly generate a random number
Egn.generate
=> '6101047500'

# Validate a given number
Egn.validate('6101047500')
=> true

# Create an new EGN object with a random number
egn = Egn::Egn.new
=> 9212094524

# OR generate EGN for a specific date
egn = Egn::Egn.new(year: 1945, month: 5, day: 8)
=> 4505085346

# OR parse an existing one
egn = Egn.parse('6101047500')
=> 6101047500

egn.birth_date
=> #<Date: 1961-01-04 ((2437304j,0s,0n),+0s,2299161j)>

egn.year
=> 1961

egn.month
=> 1

egn.day
=> 10

egn.gender # egn.sex can also be used
=> :male

egn.gender(format: :char)
=> 'm'

egn.gender(format: :number)
=> 1

egn.valid?
=> true

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

egn's People

Contributors

gmitrev avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.