Class: TinValid::ItalyTin

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/tin_valid/italy_tin.rb

Overview

rubocop:disable Metrics/ClassLength

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tin:, birth_date: nil) ⇒ ItalyTin

Returns a new instance of ItalyTin.



8
9
10
11
# File 'lib/tin_valid/italy_tin.rb', line 8

def initialize(tin:, birth_date: nil)
  @tin = tin
  @birth_date = birth_date
end

Instance Attribute Details

#birth_dateObject (readonly)

Returns the value of attribute birth_date.



13
14
15
# File 'lib/tin_valid/italy_tin.rb', line 13

def birth_date
  @birth_date
end

#tinObject (readonly)

Returns the value of attribute tin.



13
14
15
# File 'lib/tin_valid/italy_tin.rb', line 13

def tin
  @tin
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
21
# File 'lib/tin_valid/italy_tin.rb', line 15

def valid?
  match = MATCHER.match(tin)
  return false unless match
  return false unless valid_date?(match)

  tin[-1] == check
end