Class: PrepareRegexp
Class Method Summary collapse
Instance Method Summary collapse
-
#create(ignore_case, verbose, roman, &b) ⇒ Object
end.
-
#initialize(pattern) ⇒ PrepareRegexp
constructor
A new instance of PrepareRegexp.
Constructor Details
#initialize(pattern) ⇒ PrepareRegexp
Returns a new instance of PrepareRegexp.
2 3 4 |
# File 'lib/regexp.rb', line 2 def initialize(pattern) @s = pattern end |
Class Method Details
.each(options) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/regexp.rb', line 25 def self.each() [:filter].each do |f| if f.regexp.is_a? PrepareRegexp f.regexp = yield :filter, f.regexp end end .each do |k, v| if v.is_a? PrepareRegexp [k] = yield k, v end end end |
Instance Method Details
#create(ignore_case, verbose, roman, &b) ⇒ Object
end
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/regexp.rb', line 11 def create(ignore_case, verbose, roman, &b) begin c = verbose ? VerboseRegexp : Regexp o = ignore_case ? Regexp::IGNORECASE : nil s = roman ? @s.gsub('(roman)', "(#{Regexp.ROMAN_PATTERN})") : @s r = c.new s, o r.result_proc = b if verbose r rescue b.call :error, "Error parsing regular expression:\n#{$!}" nil end end |