diff options
Diffstat (limited to 'lib')
-rwxr-xr-x[-rw-r--r--] | lib/csv.rb | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/csv.rb b/lib/csv.rb index 1f616803aa..732d4f1bd6 100644..100755 --- a/lib/csv.rb +++ b/lib/csv.rb @@ -970,7 +970,7 @@ class CSV date: lambda { |f| begin e = f.encode(ConverterEncoding) - e =~ DateMatcher ? Date.parse(e) : f + e.match?(DateMatcher) ? Date.parse(e) : f rescue # encoding conversion or date parse errors f end @@ -978,7 +978,7 @@ class CSV date_time: lambda { |f| begin e = f.encode(ConverterEncoding) - e =~ DateTimeMatcher ? DateTime.parse(e) : f + e.match?(DateTimeMatcher) ? DateTime.parse(e) : f rescue # encoding conversion or date parse errors f end @@ -1271,7 +1271,7 @@ class CSV begin f = File.open(filename, mode, file_opts) rescue ArgumentError => e - raise unless /needs binmode/ =~ e.message and mode == "r" + raise unless /needs binmode/.match?(e.message) and mode == "r" mode = "rb" file_opts = {encoding: Encoding.default_external}.merge(file_opts) retry @@ -1870,7 +1870,7 @@ class CSV if part.end_with?(@quote_char) && part.count(@quote_char) % 2 != 0 # extended column ends csv.last << part[0..-2] - if csv.last =~ @parsers[:stray_quote] + if csv.last.match?(@parsers[:stray_quote]) raise MalformedCSVError, "Missing or stray quote in line #{lineno + 1}" end @@ -1888,7 +1888,7 @@ class CSV elsif part.end_with?(@quote_char) # regular quoted column csv << part[1..-2] - if csv.last =~ @parsers[:stray_quote] + if csv.last.match?(@parsers[:stray_quote]) raise MalformedCSVError, "Missing or stray quote in line #{lineno + 1}" end @@ -1899,9 +1899,9 @@ class CSV raise MalformedCSVError, "Missing or stray quote in line #{lineno + 1}" end - elsif part =~ @parsers[:quote_or_nl] + elsif part.match?(@parsers[:quote_or_nl]) # Unquoted field with bad characters. - if part =~ @parsers[:nl_or_lf] + if part.match?(@parsers[:nl_or_lf]) raise MalformedCSVError, "Unquoted fields do not allow " + "\\r or \\n (line #{lineno + 1})." else |