summaryrefslogtreecommitdiff
path: root/lib/csv/match_p.rb
blob: 775559a3ebfbe6cca155cece43351217ec4ac9d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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