class Mustermann::SimpleMatch
Fakes MatchData for patterns that do not support capturing. @see ruby-doc.org/core-2.0/MatchData.html MatchData
Public Class Methods
Source
# File lib/mustermann/simple_match.rb, line 7 def initialize(string = "", names: [], captures: []) @string = string.dup @names = names @captures = captures end
@api private
Public Instance Methods
Source
# File lib/mustermann/simple_match.rb, line 38 def +(other) SimpleMatch.new(@string + other.to_s, names: @names + other.names, captures: @captures + other.captures) end
@!visibility private
Source
# File lib/mustermann/simple_match.rb, line 29 def [](*args) args.map! do |arg| next arg unless arg.is_a? Symbol or arg.is_a? String names.index(arg.to_s) end @captures[*args] end
@return [nil] imitates MatchData interface
Source
# File lib/mustermann/simple_match.rb, line 24 def captures @captures.dup end
@return [Array<String>] empty array for imitating MatchData interface
Source
# File lib/mustermann/simple_match.rb, line 45 def inspect "#<%p %p>" % [self.class, @string] end
@return [String] string representation
Source
# File lib/mustermann/simple_match.rb, line 19 def names @names.dup end
@return [Array<String>] empty array for imitating MatchData interface
Source
# File lib/mustermann/simple_match.rb, line 14 def to_s @string.dup end
@return [String] the string that was matched against