def extract(uri_or_match, post_processing = DEFAULT_PROCESSING )
if uri_or_match.kind_of? String
m = self.to_r.match(uri_or_match)
elsif uri_or_match.kind_of?(MatchData)
if uri_or_match.respond_to?(:regexp) and uri_or_match.regexp != self.to_r
raise ArgumentError, "Trying to extract variables from MatchData which was not generated by this template."
end
m = uri_or_match
elsif uri_or_match.nil?
return nil
else
raise ArgumentError, "Expected to receive a String or a MatchData, but got #{uri_or_match.inspect}."
end
if m.nil?
return nil
else
result = extract_matchdata(m, post_processing)
if block_given?
return yield result
end
return result
end
end