Class: TinValid::LithuaniaTin
- Inherits:
-
Object
- Object
- TinValid::LithuaniaTin
- Defined in:
- lib/tin_valid/lithuania_tin.rb
Instance Attribute Summary collapse
-
#birth_date ⇒ Object
readonly
Returns the value of attribute birth_date.
-
#tin ⇒ Object
readonly
Returns the value of attribute tin.
Instance Method Summary collapse
-
#initialize(tin:, birth_date: nil) ⇒ LithuaniaTin
constructor
A new instance of LithuaniaTin.
- #valid? ⇒ Boolean
Constructor Details
#initialize(tin:, birth_date: nil) ⇒ LithuaniaTin
Returns a new instance of LithuaniaTin.
5 6 7 8 |
# File 'lib/tin_valid/lithuania_tin.rb', line 5 def initialize(tin:, birth_date: nil) @tin = tin @birth_date = birth_date end |
Instance Attribute Details
#birth_date ⇒ Object (readonly)
Returns the value of attribute birth_date.
10 11 12 |
# File 'lib/tin_valid/lithuania_tin.rb', line 10 def birth_date @birth_date end |
#tin ⇒ Object (readonly)
Returns the value of attribute tin.
10 11 12 |
# File 'lib/tin_valid/lithuania_tin.rb', line 10 def tin @tin end |
Instance Method Details
#valid? ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tin_valid/lithuania_tin.rb', line 12 def valid? matcher = MATCHER.match(tin) return false unless matcher if birth_date && (matcher[:birth_date] != birth_date.strftime("%y%m%d")) return false end tin[-1].to_i == check end |