lib/sec_id/sedol.rb in sec_id-4.0.0 vs lib/sec_id/sedol.rb in sec_id-4.1.0
- old
+ new
@@ -15,12 +15,14 @@
@identifier = sedol_parts[:identifier]
@check_digit = sedol_parts[:check_digit]&.to_i
end
def calculate_check_digit
- return mod10(weighted_sum) if valid_format?
+ unless valid_format?
+ raise InvalidFormatError, "SEDOL '#{full_number}' is invalid and check-digit cannot be calculated!"
+ end
- raise InvalidFormatError, "SEDOL '#{full_number}' is invalid and check-digit cannot be calculated!"
+ mod10(weighted_sum)
end
private
# NOTE: I know this isn't the most idiomatic Ruby code, but it's the fastest one