Class: Mustermann::SimpleMatch

Inherits:
Object
  • Object
show all
Defined in:
lib/mustermann/simple_match.rb

Overview

Fakes MatchData for patterns that do not support capturing.

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ SimpleMatch

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SimpleMatch.



6
7
8
# File 'lib/mustermann/simple_match.rb', line 6

def initialize(string)
  @string = string.dup
end

Instance Method Details

#[](*args) ⇒ nil

Returns imitates MatchData interface.

Returns:

  • (nil)

    imitates MatchData interface



26
27
28
# File 'lib/mustermann/simple_match.rb', line 26

def [](*args)
  captures[*args]
end

#capturesArray<String>

Returns empty array for imitating MatchData interface.

Returns:

  • (Array<String>)

    empty array for imitating MatchData interface



21
22
23
# File 'lib/mustermann/simple_match.rb', line 21

def captures
  []
end

#namesArray<String>

Returns empty array for imitating MatchData interface.

Returns:

  • (Array<String>)

    empty array for imitating MatchData interface



16
17
18
# File 'lib/mustermann/simple_match.rb', line 16

def names
  []
end

#to_sString

Returns the string that was matched against.

Returns:

  • (String)

    the string that was matched against



11
12
13
# File 'lib/mustermann/simple_match.rb', line 11

def to_s
  @string.dup
end