Class: Regexp

Inherits:
Object show all
Defined in:
lib/mug/rexproc.rb

Instance Method Summary collapse

Instance Method Details

#to_procProc

Returns a proc that accepts one argument, that matches against this regexp object.

Examples:

require 'mug/rexproc'
%w[foo bar baz].select &/\Ab/  #=> ["bar", "baz"]
%w[foo bar baz].reject &/\Ab/  #=> ["foo"]
%w[foo bar baz].find &/\Ab/    #=> "bar"

Returns:

  • (Proc)

    a proc that matches its argument against this regexp



15
16
17
# File 'lib/mug/rexproc.rb', line 15

def to_proc
  lambda {|s| self =~ s }
end