Class: MatchData

Inherits:
Object show all
Defined in:
lib/quality_extensions/regexp/named_captures.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(capture_name, *args, &block) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/quality_extensions/regexp/named_captures.rb', line 18

def method_missing(capture_name, *args, &block)
  if index = capture_names.index(capture_name)
    return self[index + 1]
  else
    super capture_name, *args, &block
  end
end

Instance Attribute Details

#capture_namesObject

Returns the value of attribute capture_names.



16
17
18
# File 'lib/quality_extensions/regexp/named_captures.rb', line 16

def capture_names
  @capture_names
end