Class: Mustermann::SimpleMatch
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/mustermann-3.0.0/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 imitating MatchData interface.
-
#initialize(string = "", names: [], captures: []) ⇒ SimpleMatch
constructor
private
A new instance of SimpleMatch.
-
#inspect ⇒ String
String representation.
-
#names ⇒ Array<String>
Empty array for imitating MatchData interface.
-
#to_s ⇒ String
The string that was matched against.
Constructor Details
#initialize(string = "", names: [], captures: []) ⇒ 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.
7 8 9 10 11 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/mustermann-3.0.0/lib/mustermann/simple_match.rb', line 7 def initialize(string = "", names: [], captures: []) @string = string.dup @names = names @captures = captures end |
Instance Method Details
#[](*args) ⇒ nil
Returns imitates MatchData interface.
29 30 31 32 33 34 35 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/mustermann-3.0.0/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 |
#captures ⇒ Array<String>
Returns empty array for imitating MatchData interface.
24 25 26 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/mustermann-3.0.0/lib/mustermann/simple_match.rb', line 24 def captures @captures.dup end |
#inspect ⇒ String
Returns string representation.
45 46 47 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/mustermann-3.0.0/lib/mustermann/simple_match.rb', line 45 def inspect "#<%p %p>" % [self.class, @string] end |
#names ⇒ Array<String>
Returns empty array for imitating MatchData interface.
19 20 21 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/mustermann-3.0.0/lib/mustermann/simple_match.rb', line 19 def names @names.dup end |
#to_s ⇒ String
Returns the string that was matched against.
14 15 16 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/mustermann-3.0.0/lib/mustermann/simple_match.rb', line 14 def to_s @string.dup end |