Class: TinValid::BulgariaTin
- Inherits:
-
Object
- Object
- TinValid::BulgariaTin
- Includes:
- Helpers
- Defined in:
- lib/tin_valid/bulgaria_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) ⇒ BulgariaTin
constructor
A new instance of BulgariaTin.
- #valid? ⇒ Boolean
Constructor Details
#initialize(tin:, birth_date: nil) ⇒ BulgariaTin
Returns a new instance of BulgariaTin.
7 8 9 10 |
# File 'lib/tin_valid/bulgaria_tin.rb', line 7 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.
12 13 14 |
# File 'lib/tin_valid/bulgaria_tin.rb', line 12 def birth_date @birth_date end |
#tin ⇒ Object (readonly)
Returns the value of attribute tin.
12 13 14 |
# File 'lib/tin_valid/bulgaria_tin.rb', line 12 def tin @tin end |
Instance Method Details
#valid? ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tin_valid/bulgaria_tin.rb', line 14 def valid? match = MATCHER.match(tin) return false unless match year = match[:year] month = match[:month] day = match[:day] return false unless accepted_date?(year, month, day) tin[-1].to_i == check end |