Class: SecID::LEI
Overview
Legal Entity Identifier (LEI) - a 20-character alphanumeric code that uniquely identifies legal entities participating in financial transactions.
Format: 4-character LOU ID + 2-character reserved + 12-character entity ID + 2-digit check digit
Constant Summary collapse
- FULL_NAME =
Human-readable name of the standard.
'Legal Entity Identifier'- ID_LENGTH =
Valid length(s) of a normalized identifier.
20- EXAMPLE =
A representative valid identifier.
'7LTWFZYICNSX8D621K86'- VALID_CHARS_REGEX =
Pattern matching the identifier's permitted character set.
/\A[0-9A-Z]+\z/- ID_REGEX =
Regular expression for parsing LEI components.
/\A (?<identifier> (?<lou_id>[0-9A-Z]{4}) (?<reserved>[0-9A-Z]{2}) (?<entity_id>[0-9A-Z]{12})) (?<check_digit>\d{2})? \z/x
Constants included from Checkable
Checkable::CHAR_TO_DIGIT, 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 12-character entity-specific identifier.
-
#lou_id ⇒ String?
readonly
The 4-character Local Operating Unit (LOU) identifier.
-
#reserved ⇒ String?
readonly
The 2-character reserved field (typically '00').
Attributes inherited from Base
Instance Method Summary collapse
-
#calculate_check_digit ⇒ Integer
The calculated 2-digit check digit (1-98).
-
#initialize(lei) ⇒ LEI
constructor
A new instance of LEI.
- #to_pretty_s ⇒ String?
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_s, #to_str
Constructor Details
#initialize(lei) ⇒ LEI
Returns a new instance of LEI.
48 49 50 51 52 53 54 55 |
# File 'lib/sec_id/lei.rb', line 48 def initialize(lei) lei_parts = parse lei @identifier = lei_parts[:identifier] @lou_id = lei_parts[:lou_id] @reserved = lei_parts[:reserved] @entity_id = lei_parts[:entity_id] @check_digit = lei_parts[:check_digit]&.to_i end |
Instance Attribute Details
#entity_id ⇒ String? (readonly)
Returns the 12-character entity-specific identifier.
45 46 47 |
# File 'lib/sec_id/lei.rb', line 45 def entity_id @entity_id end |
#lou_id ⇒ String? (readonly)
Returns the 4-character Local Operating Unit (LOU) identifier.
39 40 41 |
# File 'lib/sec_id/lei.rb', line 39 def lou_id @lou_id end |
#reserved ⇒ String? (readonly)
Returns the 2-character reserved field (typically '00').
42 43 44 |
# File 'lib/sec_id/lei.rb', line 42 def reserved @reserved end |
Instance Method Details
#calculate_check_digit ⇒ Integer
Returns the calculated 2-digit check digit (1-98).
66 67 68 69 |
# File 'lib/sec_id/lei.rb', line 66 def calculate_check_digit validate_format_for_calculation! mod97("#{numeric_identifier}00") end |
#to_pretty_s ⇒ String?
58 59 60 61 62 |
# File 'lib/sec_id/lei.rb', line 58 def to_pretty_s return nil unless valid? to_s.scan(/.{1,4}/).join(' ') end |