Class: Regexp

Inherits:
Object show all
Defined in:
lib/origen/core_ext/regexp.rb

Instance Method Summary collapse

Instance Method Details

#to_txt(options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/origen/core_ext/regexp.rb', line 3

def to_txt(options = {})
  options = {
    no_mods: false
  }.update(options)
  expr, mods = '', ''
  if to_yaml.match(/regexp\s+\/(.*)\/(.*)/).nil?
    Origen.log.error('Cannot convert the regular expression to text, something changed in the YAML view of the regular expressions')
    fail
  else
    (expr, mods) = to_yaml.match(/regexp\s+\/(.*)\/(.*)/).captures
  end
  options[:no_mods] ? "\/#{expr}\/" : "\/#{expr}\/#{mods}"
end