Class: SecId::SEDOL
Overview
Constant Summary collapse
- ID_REGEX =
/\A (?<identifier>[0-9BCDFGHJKLMNPQRSTVWXYZ]{6}) (?<check_digit>\d)? \z/x.freeze
- CHARACTER_WEIGHTS =
[1, 3, 1, 7, 3, 9].freeze
Constants inherited from Base
Base::CHAR_TO_DIGIT, Base::CHAR_TO_DIGITS
Instance Attribute Summary collapse
-
#full_number ⇒ Object
readonly
Returns the value of attribute full_number.
Attributes inherited from Base
Instance Method Summary collapse
- #calculate_check_digit ⇒ Object
-
#initialize(sedol) ⇒ SEDOL
constructor
A new instance of SEDOL.
Methods inherited from Base
check_digit, restore!, #restore!, #to_s, valid?, #valid?, valid_format?, #valid_format?
Constructor Details
#initialize(sedol) ⇒ SEDOL
15 16 17 18 19 |
# File 'lib/sec_id/sedol.rb', line 15 def initialize(sedol) sedol_parts = parse sedol @identifier = sedol_parts[:identifier] @check_digit = sedol_parts[:check_digit]&.to_i end |
Instance Attribute Details
#full_number ⇒ Object (readonly)
Returns the value of attribute full_number.
13 14 15 |
# File 'lib/sec_id/sedol.rb', line 13 def full_number @full_number end |
Instance Method Details
#calculate_check_digit ⇒ Object
21 22 23 24 25 |
# File 'lib/sec_id/sedol.rb', line 21 def calculate_check_digit return mod_10(weighted_sum) if valid_format? raise InvalidFormatError, "SEDOL '#{full_number}' is invalid and check-digit cannot be calculated!" end |