Class: ReferenceValidator::ValidateEan
- Inherits:
-
Object
- Object
- ReferenceValidator::ValidateEan
- Defined in:
- lib/reference_validator/validate_ean.rb
Constant Summary collapse
- DEFAULT_CODE_LENGTH =
18
- MAX_CODE_LENGTH =
13
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
Instance Method Summary collapse
-
#initialize(code) ⇒ ValidateEan
constructor
A new instance of ValidateEan.
- #validate! ⇒ Object
Constructor Details
#initialize(code) ⇒ ValidateEan
Returns a new instance of ValidateEan.
13 14 15 |
# File 'lib/reference_validator/validate_ean.rb', line 13 def initialize(code) @code = code end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/reference_validator/validate_ean.rb', line 8 def code @code end |
Instance Method Details
#validate! ⇒ Object
17 18 19 20 21 |
# File 'lib/reference_validator/validate_ean.rb', line 17 def validate! return true if code.present? && format_valid? && checksum_valid? false end |