Class: MODL::Parser::Substitutions
- Inherits:
-
Object
- Object
- MODL::Parser::Substitutions
- Defined in:
- lib/modl/parser/substitutions.rb
Overview
Escape-sequence replacements for MODL files.
Constant Summary collapse
- @@subs =
[ ['~\\', '\\'], ['\\\\', '\\'], ['~~', '~'], ['\\~', '~'], ['~(', '('], ['\\(', '('], ['~)', ')'], ['\\)', ')'], ['~[', '['], ['\\[', '['], ['~]', ']'], ['\\]', ']'], ['~{', '{'], ['\\{', '{'], ['~}', '}'], ['\\}', '}'], ['~;', ';'], ['\\;', ';'], ['~:', ':'], ['\\:', ':'], ['~`', '`'], ['\\`', '`'], ['~"', '"'], ['\\"', '"'], ['~=', '='], ['\\=', '='], ['~/', '/'], ['\\/', '/'], ['<', '<'], ['\\<', '<'], ['~>', '>'], ['\\>', '>'], ['~&', '&'], ['\\&', '&'], ['!', '!'], ['\\!', '!'], ['~|', '|'], ['\\|', '|'], ['\\t', "\t"], ['\\n', "\n"], ['\\b', "\b"], ['\\f', "\f"], ['\\r', "\r"] ]
Class Method Summary collapse
-
.process(str) ⇒ Object
Replace all escape sequences in the supplied string and return the new value.
Class Method Details
.process(str) ⇒ Object
Replace all escape sequences in the supplied string and return the new value.
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/modl/parser/substitutions.rb', line 55 def self.process(str) @@subs.each do |s| loop do prev = str str = str.sub(s[0], s[1]) break unless str && str != prev end end str end |