Class: Regexp

Inherits:
Object show all
Defined in:
lib/opium/extensions/regexp.rb

Instance Method Summary collapse

Instance Method Details

#to_parseObject



2
3
4
5
6
7
8
9
10
11
# File 'lib/opium/extensions/regexp.rb', line 2

def to_parse
  { '$regex' => self.source }.tap do |h|
    ops = ''
    { IGNORECASE => 'i', MULTILINE => 'm', EXTENDED => 'x' }.each do |option, value|
      ops += value unless ( self.options & option ) == 0
    end
    
    h['$options'] = ops unless ops.blank?
  end
end