Class: Uy::Id
- Inherits:
-
Object
- Object
- Uy::Id
- Defined in:
- lib/uy/id.rb
Constant Summary collapse
- FACTORS =
[2,9,8,7,6,3,4]
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(id = nil) ⇒ Id
constructor
A new instance of Id.
- #is_valid? ⇒ Boolean (also: #valid?)
Constructor Details
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/uy/id.rb', line 5 def id @id end |
Instance Method Details
#is_valid? ⇒ Boolean Also known as: valid?
11 12 13 14 15 16 |
# File 'lib/uy/id.rb', line 11 def is_valid? return false unless @id =~ /\d{8}/ return false unless Id.calculate_check_digit(@id) == @id[7].to_i true end |