Sha256: 635908acb163341de79ee8222141c62f17a67aeddcf1fe6454804aeed5e769cb

Contents?: true

Size: 361 Bytes

Versions: 27

Compression:

Stored size: 361 Bytes

Contents

module CoreExtensions
  module MatchData
    # named_captures was introduced in Ruby 2.4.0
    if RUBY_VERSION =~ /^2.3/
      def named_captures
        names.zip(captures).to_h
      end
    end

    def capture index
      case index
      when Symbol, String
        named_captures[index.to_s]
      else
        captures[index]
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
card-1.100.0 config/initializers/01_core_extensions/match_data.rb
card-1.99.6 config/initializers/01_core_extensions/match_data.rb
card-1.99.5 config/initializers/01_core_extensions/match_data.rb
card-1.99.4 config/initializers/01_core_extensions/match_data.rb
card-1.99.3 config/initializers/01_core_extensions/match_data.rb
card-1.99.2 config/initializers/01_core_extensions/match_data.rb
card-1.99.1 config/initializers/01_core_extensions/match_data.rb
card-1.99.0 config/initializers/01_core_extensions/match_data.rb
card-1.98.3 config/initializers/01_core_extensions/match_data.rb
card-1.98.2 config/initializers/01_core_extensions/match_data.rb
card-1.98.1 config/initializers/01_core_extensions/match_data.rb
card-1.98.0 config/initializers/01_core_extensions/match_data.rb
card-1.97.0.1 config/initializers/01_core_extensions/match_data.rb
card-1.97.0 config/initializers/01_core_extensions/match_data.rb
card-1.96.8 config/initializers/01_core_extensions/match_data.rb
card-1.96.7 config/initializers/01_core_extensions/match_data.rb
card-1.96.6 config/initializers/01_core_extensions/match_data.rb
card-1.96.5 config/initializers/01_core_extensions/match_data.rb
card-1.96.4 config/initializers/01_core_extensions/match_data.rb
card-1.96.3 config/initializers/01_core_extensions/match_data.rb