Class: TinValid::AustriaTin
- Inherits:
-
Object
- Object
- TinValid::AustriaTin
- Defined in:
- lib/tin_valid/austria_tin.rb
Instance Attribute Summary collapse
-
#tin ⇒ Object
readonly
Returns the value of attribute tin.
Instance Method Summary collapse
-
#initialize(tin:) ⇒ AustriaTin
constructor
A new instance of AustriaTin.
- #normalized ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(tin:) ⇒ AustriaTin
Returns a new instance of AustriaTin.
5 6 7 |
# File 'lib/tin_valid/austria_tin.rb', line 5 def initialize(tin:) @tin = tin end |
Instance Attribute Details
#tin ⇒ Object (readonly)
Returns the value of attribute tin.
9 10 11 |
# File 'lib/tin_valid/austria_tin.rb', line 9 def tin @tin end |
Instance Method Details
#normalized ⇒ Object
18 19 20 |
# File 'lib/tin_valid/austria_tin.rb', line 18 def normalized @normalized ||= tin.to_s.strip.tr("-/", "") end |
#valid? ⇒ Boolean
11 12 13 14 15 16 |
# File 'lib/tin_valid/austria_tin.rb', line 11 def valid? return false unless MATCHER.match?(normalized) return false if %w[000000000 123456789].include?(normalized) normalized[-1] == check end |