lib/sec_id/cusip.rb in sec_id-3.0.0 vs lib/sec_id/cusip.rb in sec_id-4.0.0
- old
+ new
@@ -6,11 +6,11 @@
ID_REGEX = /\A
(?<identifier>
(?<cusip6>[A-Z0-9]{5}[A-Z0-9*@#])
(?<issue>[A-Z0-9*@#]{2}))
(?<check_digit>\d)?
- \z/x.freeze
+ \z/x
attr_reader :cusip6, :issue
def initialize(cusip)
cusip_parts = parse cusip
@@ -19,11 +19,11 @@
@issue = cusip_parts[:issue]
@check_digit = cusip_parts[:check_digit]&.to_i
end
def calculate_check_digit
- return mod_10(modified_luhn_sum) if valid_format?
+ return mod10(modified_luhn_sum) if valid_format?
raise InvalidFormatError, "CUSIP '#{full_number}' is invalid and check-digit cannot be calculated!"
end
private
@@ -32,10 +32,10 @@
def modified_luhn_sum
sum = 0
id_digits.reverse.each_slice(2) do |even, odd|
double_even = (even || 0) * 2
- sum += div_10_mod_10(double_even) + div_10_mod_10(odd || 0)
+ sum += div10mod10(double_even) + div10mod10(odd || 0)
end
sum
end