Class: Regexp
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( = {}) = { no_mods: false }.update() 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 [:no_mods] ? "\/#{expr}\/" : "\/#{expr}\/#{mods}" end |