aboutsummaryrefslogtreecommitdiffstats
path: root/lib/csv/match_p.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-23 07:00:35 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-23 07:00:35 +0000
commite5d634260e7927db284fd7d2d656899443f5c53e (patch)
tree31f579715ae8c73ee8094c258b634f1186a0946a /lib/csv/match_p.rb
parentc20a1946a6d7b260f1f0f3038b7af081174d6cd9 (diff)
downloadruby-e5d634260e7927db284fd7d2d656899443f5c53e.tar.gz
Import CSV 3.0.2
This includes performance improvement especially writing. Writing is about 2 times faster. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/csv/match_p.rb')
-rw-r--r--lib/csv/match_p.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/csv/match_p.rb b/lib/csv/match_p.rb
new file mode 100644
index 0000000000..775559a3eb
--- /dev/null
+++ b/lib/csv/match_p.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+# This provides String#match? and Regexp#match? for Ruby 2.3.
+unless String.method_defined?(:match?)
+ class CSV
+ module MatchP
+ refine String do
+ def match?(pattern)
+ self =~ pattern
+ end
+ end
+
+ refine Regexp do
+ def match?(string)
+ self =~ string
+ end
+ end
+ end
+ end
+end