Class: ReferenceValidator::ValidateEan

Inherits:
Object
  • Object
show all
Defined in:
lib/reference_validator/validate_ean.rb

Constant Summary collapse

DEFAULT_CODE_LENGTH =
18
MAX_CODE_LENGTH =
13

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#codeObject (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