Method: Regexp#to_proc

Defined in:
lib/core/facets/regexp/to_proc.rb

#to_procObject

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.



9
10
11
# File 'lib/core/facets/regexp/to_proc.rb', line 9

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