Class: Eid::Finland
Constant Summary
collapse
- VALID_CENTURY_SIGNS =
NOTE: identity DDMMYYCZZZQ DDMMYY - date of birth C - century sign (+, -, U, V, W, X, Y, A, B, C, D, E, F) ZZZ - individual number (002-899 for permanent residents and Finnish citizens, 900-999 for temporary IDs) Q - control character (checksum)
%w[+ - U V W X Y A B C D E F].freeze
- VALID_CONTROL_CHARACTERS =
'0123456789ABCDEFHJKLMNPRSTUVWXY'
Instance Attribute Summary
Attributes inherited from Core
#identity
Instance Method Summary
collapse
Methods inherited from Core
#age, #gender, #initialize
Constructor Details
This class inherits a constructor from Eid::Core
Instance Method Details
#birth_date ⇒ Object
30
31
32
33
34
|
# File 'lib/eid/finland.rb', line 30
def birth_date
Date.new(century + identity[4..5].to_i, identity[2..3].to_i, identity[0..1].to_i)
rescue StandardError
nil
end
|
#female? ⇒ Boolean
22
23
24
|
# File 'lib/eid/finland.rb', line 22
def female?
identity[7..9].to_i.even?
end
|
#male? ⇒ Boolean
26
27
28
|
# File 'lib/eid/finland.rb', line 26
def male?
identity[7..9].to_i.odd?
end
|
#valid? ⇒ Boolean
14
15
16
17
18
19
20
|
# File 'lib/eid/finland.rb', line 14
def valid?
return false unless identity.size == 11
birth_date.is_a?(Date) &&
VALID_CENTURY_SIGNS.include?(identity[6]) &&
VALID_CONTROL_CHARACTERS.include?(identity[10])
end
|