Sha256: 44b4c2df6277c0f28331287a76910ddebcef278bd23dcefc052ebbb2e6a3d780

Contents?: true

Size: 505 Bytes

Versions: 1

Compression:

Stored size: 505 Bytes

Contents

# frozen_string_literal: true

require_relative "ukrainian_id_number/version"
require 'date'

module UkrainianIdNumber
  class Error < StandardError; end

  class Processor
    attr_reader :id_number, :start_date, :birthday
    def initialize(id_number)
      @id_number = id_number
      @start_date = Date.parse('1 Jan 1900')
    end

    def call
      @birthday = (start_date + birthday_token.to_i) - 1

      self
    end

    private

    def birthday_token
      @id_number[0..4]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ukrainian_id_number-1.0.0 lib/ukrainian_id_number.rb