Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/utilities.rb
Overview
This just helps in a couple places, and I’m putting it here.
Instance Method Summary collapse
Instance Method Details
#to_re ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/utilities.rb', line 3 def to_re source, = ( /^\/(.*)\/([^\/]*)$/.match(self) )? [$1, $2] : [self,nil] mods = 0 .each_char do |c| mods |= case c when 'i' then Regexp::IGNORECASE when 'x' then Regexp::EXTENDED when 'm' then Regexp::MULTILINE end end unless .nil? or .empty? Regexp.new source, mods end |