Sha256: effcd69db0de656d8106258f62592065fe907d8e97137facfe30127e2b8d0466

Contents?: true

Size: 674 Bytes

Versions: 1

Compression:

Stored size: 674 Bytes

Contents

module Mustermann
  # Fakes MatchData for patterns that do not support capturing.
  # @see http://ruby-doc.org/core-2.0/MatchData.html MatchData
  class SimpleMatch
    # @api private
    def initialize(string)
      @string = string.dup
    end

    # @return [String] the string that was matched against
    def to_s
      @string.dup
    end

    # @return [Array<String>] empty array for immitating MatchData interface
    def names
      []
    end

    # @return [Array<String>] empty array for immitating MatchData interface
    def captures
      []
    end

    # @return [nil] imitates MatchData interface
    def [](*args)
      captures[*args]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mustermann-0.0.1 lib/mustermann/simple_match.rb