Skip to content

Commit

Permalink
Add Regexp#to_proc.
Browse files Browse the repository at this point in the history
  • Loading branch information
trans committed Apr 10, 2014
1 parent 45cbfac commit 9c5b394
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Expand Up @@ -6,13 +6,17 @@ Major release is now for Ruby 1.9.2+. Ruby 1.8 and older is no longer supported.
If you still need to use Facets with Ruby 1.8 or older then the excellent
Backports project can be used to fill in the gaps.

Special thanks to Seam Mackesey for contributing some new methods.


Changes:

* New Features

* Add alias String#each_match for #mscan.
* Add Dir.lookup method.
* Add Proc.wrap (may become `Kernel#Proc()`).
* Add Regexp#to_proc.

* Renamed Features

Expand Down
13 changes: 13 additions & 0 deletions lib/core/facets/regexp/to_proc.rb
@@ -0,0 +1,13 @@
class Regexp

# Useful to pass a Regexp as a block that will match elements
#
# %w[ joe_the_dog mary_the_cat ].index &/cat/ #=> 1
#
# Returns [Proc] which passes it's argument to Regexp#match method.

def to_proc
proc { |x| match(x) }
end

end

0 comments on commit 9c5b394

Please sign in to comment.