Module: SecId::Checkable::ClassMethods

Defined in:
lib/sec_id/concerns/checkable.rb

Overview

Class methods added when Checkable is included.

Instance Method Summary collapse

Instance Method Details

#check_digit(id) ⇒ Integer

Returns the calculated check digit.

Parameters:

  • id (String)

    the identifier to calculate check digit for

Returns:

  • (Integer)

    the calculated check digit

Raises:



78
79
80
# File 'lib/sec_id/concerns/checkable.rb', line 78

def check_digit(id)
  new(id).calculate_check_digit
end

#restore!(id_without_check_digit) ⇒ String

Restores (calculates) the check digit and returns the full identifier.

Parameters:

  • id_without_check_digit (String)

    identifier without or with incorrect check digit

Returns:

  • (String)

    the full identifier with correct check digit

Raises:



71
72
73
# File 'lib/sec_id/concerns/checkable.rb', line 71

def restore!(id_without_check_digit)
  new(id_without_check_digit).restore!
end