lib/sec_id/sedol.rb in sec_id-2.0.1 vs lib/sec_id/sedol.rb in sec_id-3.0.0

- old
+ new

@@ -8,12 +8,10 @@ (?<check_digit>\d)? \z/x.freeze CHARACTER_WEIGHTS = [1, 3, 1, 7, 3, 9].freeze - attr_reader :full_number - def initialize(sedol) sedol_parts = parse sedol @identifier = sedol_parts[:identifier] @check_digit = sedol_parts[:check_digit]&.to_i end @@ -29,18 +27,18 @@ # NOTE: I know this isn't the most idiomatic Ruby code, but it's the fastest one def weighted_sum index = 0 sum = 0 - while index < digitized_identifier.size - sum += digitized_identifier[index] * CHARACTER_WEIGHTS[index] + while index < id_digits.size + sum += id_digits[index] * CHARACTER_WEIGHTS[index] index += 1 end sum end - def digitized_identifier - @digitized_identifier ||= identifier.each_char.map(&method(:char_to_digit)) + def id_digits + @id_digits ||= identifier.each_char.map(&method(:char_to_digit)) end end end