Class: Mustermann::SimpleMatch
- Inherits:
-
Object
- Object
- Mustermann::SimpleMatch
- Defined in:
- lib/mustermann/simple_match.rb
Overview
Fakes MatchData for patterns that do not support capturing.
Instance Method Summary collapse
-
#[](*args) ⇒ nil
Imitates MatchData interface.
-
#captures ⇒ Array<String>
Empty array for immitating MatchData interface.
-
#initialize(string) ⇒ SimpleMatch
constructor
private
A new instance of SimpleMatch.
-
#names ⇒ Array<String>
Empty array for immitating MatchData interface.
-
#to_s ⇒ String
The string that was matched against.
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.
26 27 28 |
# File 'lib/mustermann/simple_match.rb', line 26 def [](*args) captures[*args] end |
#captures ⇒ Array<String>
Returns empty array for immitating MatchData interface.
21 22 23 |
# File 'lib/mustermann/simple_match.rb', line 21 def captures [] end |
#names ⇒ Array<String>
Returns empty array for immitating MatchData interface.
16 17 18 |
# File 'lib/mustermann/simple_match.rb', line 16 def names [] end |
#to_s ⇒ String
Returns the string that was matched against.
11 12 13 |
# File 'lib/mustermann/simple_match.rb', line 11 def to_s @string.dup end |