Class: Eid::Latvia

Inherits:
Core
  • Object
show all
Defined in:
lib/eid/latvia.rb

Instance Attribute Summary

Attributes inherited from Core

#identity

Instance Method Summary collapse

Methods inherited from Core

#age, #initialize

Constructor Details

This class inherits a constructor from Eid::Core

Instance Method Details

#birth_dateObject



36
37
38
39
40
# File 'lib/eid/latvia.rb', line 36

def birth_date
  Date.new(century + identity[4..5].to_i, identity[2..3].to_i, identity[0..1].to_i) if legacy?
rescue StandardError
  nil
end

#female?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/eid/latvia.rb', line 24

def female?
  raise 'Not supported'
end

#genderObject



32
33
34
# File 'lib/eid/latvia.rb', line 32

def gender
  raise 'Not supported'
end

#legacy?Boolean

NOTE: identity DDMMYY-XNNNZ DDMYY - date of birth X - century NNN - birth serial number Z - checksum digit

32XXXX-XXXXC (updated format since 01.07.2017) 32 - updated format indicator XXXX-XXXX - random numbers C - checksum

Returns:

  • (Boolean)


16
17
18
# File 'lib/eid/latvia.rb', line 16

def legacy?
  !identity.start_with?('32')
end

#male?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/eid/latvia.rb', line 28

def male?
  raise 'Not supported'
end

#valid?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/eid/latvia.rb', line 20

def valid?
  legacy? ? (valid_format? && birth_date.is_a?(Date)) : valid_format?
end