Class: SecID::CEI
- Includes:
- Checkable, Suggestable
- Defined in:
- lib/sec_id/cei.rb
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 checksum
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})) (?<checksum>\d)? \z/x
Constants included from Suggestable
Suggestable::HOMOGLYPHS, Suggestable::RANK
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_checksum ⇒ Integer
The calculated checksum (0-9).
-
#initialize(cei) ⇒ CEI
constructor
A new instance of CEI.
Methods included from Suggestable
Methods included from Checkable
#calculate_check_digit, #check_digit, #restore, #restore!, #to_s, #valid?
Methods inherited from Base
#==, #as_json, #deconstruct_keys, detection_priority, example, full_name, has_check_digit?, has_checksum?, #hash, id_length, length_specificity, length_values, short_name, #to_h, type_key
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.
45 46 47 48 49 50 51 52 |
# File 'lib/sec_id/cei.rb', line 45 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] @checksum = cei_parts[:checksum]&.to_i end |
Instance Attribute Details
#entity_id ⇒ String? (readonly)
Returns the 7-character entity identifier.
42 43 44 |
# File 'lib/sec_id/cei.rb', line 42 def entity_id @entity_id end |
#numeric ⇒ String? (readonly)
Returns the second character (numeric).
39 40 41 |
# File 'lib/sec_id/cei.rb', line 39 def numeric @numeric end |
#prefix ⇒ String? (readonly)
Returns the first character (alphabetic).
36 37 38 |
# File 'lib/sec_id/cei.rb', line 36 def prefix @prefix end |
Instance Method Details
#calculate_checksum ⇒ Integer
Returns the calculated checksum (0-9).
56 57 58 59 |
# File 'lib/sec_id/cei.rb', line 56 def calculate_checksum validate_format_for_calculation! mod10(luhn_sum_double_add_double(reversed_digits_single(identifier))) end |