Class: TinValid::Tin
- Inherits:
-
Object
- Object
- TinValid::Tin
- Defined in:
- lib/tin_valid/tin.rb
Instance Attribute Summary collapse
-
#birth_date ⇒ Object
readonly
Returns the value of attribute birth_date.
-
#country_code ⇒ Object
readonly
Returns the value of attribute country_code.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#tin ⇒ Object
readonly
Returns the value of attribute tin.
Instance Method Summary collapse
-
#initialize(country_code:, tin:, birth_date: nil, kind: nil) ⇒ Tin
constructor
A new instance of Tin.
-
#valid? ⇒ Boolean
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize(country_code:, tin:, birth_date: nil, kind: nil) ⇒ Tin
5 6 7 8 9 10 |
# File 'lib/tin_valid/tin.rb', line 5 def initialize(country_code:, tin:, birth_date: nil, kind: nil) @country_code = country_code @tin = tin @birth_date = birth_date @kind = kind end |
Instance Attribute Details
#birth_date ⇒ Object (readonly)
Returns the value of attribute birth_date.
12 13 14 |
# File 'lib/tin_valid/tin.rb', line 12 def birth_date @birth_date end |
#country_code ⇒ Object (readonly)
Returns the value of attribute country_code.
12 13 14 |
# File 'lib/tin_valid/tin.rb', line 12 def country_code @country_code end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
12 13 14 |
# File 'lib/tin_valid/tin.rb', line 12 def kind @kind end |
#tin ⇒ Object (readonly)
Returns the value of attribute tin.
12 13 14 |
# File 'lib/tin_valid/tin.rb', line 12 def tin @tin end |
Instance Method Details
#valid? ⇒ Boolean
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/MethodLength
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/tin_valid/tin.rb', line 18 def valid? case country_code in "at" then AustriaTin.new(tin:).valid? in "be" then BelgiumTin.new(tin:, birth_date:).valid? in "bg" then BulgariaTin.new(tin:, birth_date:).valid? in "cy" then CyprusTin.new(tin:, kind:).valid? in "cz" then CzechiaTin.new(tin:, birth_date:).valid? in "de" then GermanyTin.new(tin:).valid? in "dk" then DenmarkTin.new(tin:, birth_date:).valid? in "ee" then EstoniaTin.new(tin:, birth_date:).valid? in "es" then SpainTin.new(tin:).valid? in "fi" then FinlandTin.new(tin:).valid? in "fr" then FranceTin.new(tin:).valid? in "gb" then UnitedKingdomTin.new(tin:).valid? in "gr" then GreeceTin.new(tin:).valid? in "hr" then CroatiaTin.new(tin:).valid? in "hu" then HungaryTin.new(tin:).valid? in "ie" then IrelandTin.new(tin:).valid? in "it" then ItalyTin.new(tin:, birth_date:).valid? in "lt" then LithuaniaTin.new(tin:, birth_date:).valid? in "lu" then LuxembourgTin.new(tin:, birth_date:).valid? in "lv" then LatviaTin.new(tin:, birth_date:).valid? in "mt" then MaltaTin.new(tin:).valid? in "nl" then NetherlandsTin.new(tin:).valid? in "pl" then PolandTin.new(tin:, birth_date:).valid? in "pt" then PortugalTin.new(tin:).valid? in "ro" then RomaniaTin.new(tin:, birth_date:).valid? in "se" then SwedenTin.new(tin:, birth_date:).valid? in "si" then SloveniaTin.new(tin:).valid? in "sk" then SlovakiaTin.new(tin:).valid? end end |