Sha256: c3465f9629fa99c7d87ea303e761ec1fff98d53415da9a46d7bf59e610355963
Contents?: true
Size: 825 Bytes
Versions: 2
Compression:
Stored size: 825 Bytes
Contents
# frozen_string_literal: true module Eid class Lithuania < Core # NOTE: identity GYYMMDDNNNC # G – gender (even for female, odd for male) # YYMMDD – date of birth # NNN – serial number # C – checksum def valid? valid_format? && birth_date.is_a?(Date) end def female? identity[0].to_i.even? end def male? identity[0].to_i.odd? end def birth_date Date.new((century + identity[1..2].to_i), identity[3..4].to_i, identity[5..6].to_i) rescue StandardError nil end private def valid_format? identity.match?(/\d{11}/) && identity.size == 11 end def century case identity[0].to_i when 1..2 then 1800 when 3..4 then 1900 when 5..6 then 2000 else 2100 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
e-id-0.3.0 | lib/eid/lithuania.rb |
e-id-0.2.0 | lib/eid/lithuania.rb |