Module: Mobj::MatchEx
- Defined in:
- lib/ext/match_data.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/ext/match_data.rb', line 8
def method_missing(name, *args, &block)
if name[-1] == '?' && names.includes?(name[0...-1])
return to_h[name[0...-1].sym]
elsif names.includes?(name.to_s)
return to_h[name.sym]
end
super
end
|
Instance Method Details
4
5
6
|
# File 'lib/ext/match_data.rb', line 4
def to_h
Hash[names.map(&:sym).zip(captures)]
end
|