lib/banktools-se/ocr.rb in banktools-se-2.6.3 vs lib/banktools-se/ocr.rb in banktools-se-3.0.0
- old
+ new
@@ -62,12 +62,12 @@
digits_to_chop += strip_padding.length
ocr[0...-digits_to_chop]
end
- # max_length is 19 because that's the longest allowed integer by default in a Postgres integer column with Ruby on Rails. So attempting some queries with longer OCRs may cause exceptions.
- def self.find_all_in_string(string, length_digit: false, pad: "", min_length: 4, max_length: 19)
+ # max_length is 18, because the biggest allowed integer by default in a Postgres integer column ("bigint") is 19 digits long, as is the next (disallowed) number. Attempting some queries with longer OCRs may cause Ruby on Rails exceptions.
+ def self.find_all_in_string(string, length_digit: false, pad: "", min_length: 4, max_length: 18)
# First, treat the input as one long string of digits.
# E.g. "1234 and 5678" becomes "12345678".
digit_string = string.gsub(/\D/, "")
@@ -86,10 +86,10 @@
end
end
# Get rid of any duplicates.
- candidates.uniq!
+ candidates = candidates.uniq
# Finally, limit these substrings to ones that are actually valid OCRs.
candidates.select { |candidate|
begin