Class: SecID::CEI
Overview
CUSIP Entity Identifier (CEI) - a 10-character alphanumeric code that identifies legal entities in the syndicated loan market.
Format: 1 alpha + 1 digit + 7 alphanumeric + 1 check digit
Constant Summary collapse
- FULL_NAME =
Human-readable name of the standard.
'CUSIP Entity Identifier'- ID_LENGTH =
Valid length(s) of a normalized identifier.
10- EXAMPLE =
A representative valid identifier.
'A0BCDEFGH1'- VALID_CHARS_REGEX =
Pattern matching the identifier's permitted character set.
/\A[A-Z0-9]+\z/- ID_REGEX =
Regular expression for parsing CEI components.
/\A (?<identifier> (?<prefix>[A-Z]) (?<numeric>[0-9]) (?<entity_id>[A-Z0-9]{7})) (?<check_digit>\d)? \z/x
Constants included from Checkable
SecID::Checkable::CHAR_TO_DIGIT, SecID::Checkable::CHAR_TO_DIGITS
Constants included from Generatable
Generatable::ALPHA, Generatable::ALPHANUMERIC, Generatable::DIGITS
Constants included from Validatable
Constants included from Normalizable
Instance Attribute Summary collapse
-
#entity_id ⇒ String?
readonly
The 7-character entity identifier.
-
#numeric ⇒ String?
readonly
The second character (numeric).
-
#prefix ⇒ String?
readonly
The first character (alphabetic).
Attributes inherited from Base
Instance Method Summary collapse
-
#calculate_check_digit ⇒ Integer
The calculated check digit (0-9).
-
#initialize(cei) ⇒ CEI
constructor
A new instance of CEI.
Methods included from Checkable
#restore, #restore!, #to_s, #valid?
Methods inherited from Base
#==, #as_json, example, full_name, has_check_digit?, #hash, id_length, length_specificity, length_values, short_name, #to_h
Methods included from Validatable
#errors, #valid?, #validate, #validate!
Methods included from Normalizable
#normalize!, #normalized, #to_pretty_s, #to_s, #to_str
Constructor Details
#initialize(cei) ⇒ CEI
Returns a new instance of CEI.
44 45 46 47 48 49 50 51 |
# File 'lib/sec_id/cei.rb', line 44 def initialize(cei) cei_parts = parse cei @identifier = cei_parts[:identifier] @prefix = cei_parts[:prefix] @numeric = cei_parts[:numeric] @entity_id = cei_parts[:entity_id] @check_digit = cei_parts[:check_digit]&.to_i end |
Instance Attribute Details
#entity_id ⇒ String? (readonly)
Returns the 7-character entity identifier.
41 42 43 |
# File 'lib/sec_id/cei.rb', line 41 def entity_id @entity_id end |
#numeric ⇒ String? (readonly)
Returns the second character (numeric).
38 39 40 |
# File 'lib/sec_id/cei.rb', line 38 def numeric @numeric end |
#prefix ⇒ String? (readonly)
Returns the first character (alphabetic).
35 36 37 |
# File 'lib/sec_id/cei.rb', line 35 def prefix @prefix end |
Instance Method Details
#calculate_check_digit ⇒ Integer
Returns the calculated check digit (0-9).
55 56 57 58 |
# File 'lib/sec_id/cei.rb', line 55 def calculate_check_digit validate_format_for_calculation! mod10(luhn_sum_double_add_double(reversed_digits_single(identifier))) end |