Sha256: 158b6690bf3aa488682ad431ef0b3e95ad93609aed0f5b082a2ca7810ebb7f0e

Contents?: true

Size: 467 Bytes

Versions: 2

Compression:

Stored size: 467 Bytes

Contents

# This just helps in a couple places, and I'm putting it here.
class String
  def to_re
    source, options = ( /^\/(.*)\/([^\/]*)$/.match(self) )? [$1, $2] : [self,nil]
    
    mods = 0
    
    options.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 options.nil? or options.empty?
        
    Regexp.new source, mods
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brisk-bills-0.8.2 lib/utilities.rb
brisk-bills-0.8.1 lib/utilities.rb