Skip to content

Commit 5ad3c71

Browse files
committed
Implement MatchData#named_captures.
1 parent 928a1db commit 5ad3c71

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,24 @@
22

33
New features:
44

5-
* Implemented `Dir.each_child`.
65
* macOS clocks `CLOCK_MONOTONIC_RAW`, `_MONOTONIC_RAW_APPROX`, `_UPTIME_RAW`,
76
`_UPTIME_RAW_APPROX`, and `_PROCESS_CPUTIME_ID` have been implemented (#1480).
87

98
Bug fixes:
109

11-
* Adding missing support for the `close_others` option to `exec` and `spawn`.
1210
* FFI::Pointer now does the correct range checks for signed and unsigned values.
1311
* Allow signal `0` to be used with `Process.kill` (#1474).
1412
* `IO#dup` now properly sets the new `IO` instance to be close-on-exec.
1513
* `IO#reopen` now properly resets the receiver to be close-on-exec.
1614
* `StringIO#set_encoding` no longer raises an exception if the underlying
1715
`String` is frozen (#1473).
1816

17+
Compatibility:
18+
19+
* Implemented `Dir.each_child`.
20+
* Adding missing support for the `close_others` option to `exec` and `spawn`.
21+
* Implemented the missing `MatchData#named_captures` method (#1512).
22+
1923
Changes:
2024

2125
* `Process::CLOCK_` constants have been given the same value as in standard

spec/tags/core/matchdata/named_captures_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/main/ruby/core/regexp.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ def names
365365
regexp.names
366366
end
367367

368+
def named_captures
369+
names.collect { |name| [name, self[name]] }.to_h
370+
end
371+
368372
def pre_match_from(idx)
369373
source = Truffle.invoke_primitive(:match_data_get_source, self)
370374
return source.byteslice(0, 0) if self.byte_begin(0) == 0

0 commit comments

Comments
 (0)