Class: NationalIdentificationNumber::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/national_identification_number/base.rb

Direct Known Subclasses

Danish, Finnish, Norwegian, Swedish

Instance Method Summary collapse

Constructor Details

#initialize(number) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
# File 'lib/national_identification_number/base.rb', line 6

def initialize(number)
  @number = number
  repair
  validate
end

Instance Method Details

#==(other) ⇒ Object



28
29
30
# File 'lib/national_identification_number/base.rb', line 28

def ==(other)
  other.class == self.class && other&.to_s == to_s
end

#ageObject



24
25
26
# File 'lib/national_identification_number/base.rb', line 24

def age
  age_for_dob date
end

#sanitizeObject



20
21
22
# File 'lib/national_identification_number/base.rb', line 20

def sanitize
  to_s if valid?
end

#to_sObject



16
17
18
# File 'lib/national_identification_number/base.rb', line 16

def to_s
  @number
end

#valid?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/national_identification_number/base.rb', line 12

def valid?
  !!@valid
end