lib/banktools-se/ocr.rb in banktools-se-2.4.0 vs lib/banktools-se/ocr.rb in banktools-se-2.5.0
- old
+ new
@@ -64,10 +64,10 @@
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)
- expanded_string = string + " " + string.gsub("\n", "") + " " + string.gsub(";", "")
+ expanded_string = [ string, *[ "\n", ";", "." ].map { |x| string.gsub(x, "") } ].join(" ")
numbers = expanded_string.scan(/\d+/)
expanded_numbers = with_numbers_found_by_removing_prefix_and_postfix(numbers).
reject { |n| n.length < min_length || n.length > max_length }