Plugin details

This plugin provides the Pesel class to check the PESEL number and get information about its owner.

Websitehttp://github.com/macuk/pesel Repositorygit://github.com/macuk/pesel.git LicenseUnknown

Documentation

Install the plugin:
ruby script/plugin install git://github.com/macuk/pesel.git

Example
=======

Standalone class:

  pesel = Pesel.new('75120804355')
  pesel.valid?      # true
  pesel.birth_date  # Date object with '1975-12-08' date
  pesel.female?     # false
  pesel.male?       # true
  pesel.gender      # :male
  pesel.number      # '75120804355'

  pesel = Pesel.new('00000000000')
  pesel.valid?      # false
  pesel.birth_date  # raises Pesel::NumberInvalid exception
  pesel.female?     # raises Pesel::NumberInvalid exception
  pesel.male?       # raises Pesel::NumberInvalid exception
  pesel.gender      # raises Pesel::NumberInvalid exception
  pesel.number      # raises Pesel::NumberInvalid exception



ActiveRecord:

  class Person < ActiveRecord::Base
    validate :check_pesel

    private
      def check_pesel
        p = Pesel.new(pesel)
        message = 'Invalid PESEL number'
        errors.add(:pesel, message) unless p.valid?
      end
  end

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: Guest, 8 months ago