Sha256: 85c659e793635b633bc5eaeb26f0d99058c81ca7c621fe4251e35a8500ad4ab7
Contents?: true
Size: 1.47 KB
Versions: 4
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true module MODL module Parser # Escape-sequence replacements for MODL files. class Substitutions @@subs = [ ['~\\', '\\'], ['\\\\', '\\'], ['~~', '~'], ['\\~', '~'], ['~(', '('], ['\\(', '('], ['~)', ')'], ['\\)', ')'], ['~[', '['], ['\\[', '['], ['~]', ']'], ['\\]', ']'], ['~{', '{'], ['\\{', '{'], ['~}', '}'], ['\\}', '}'], ['~;', ';'], ['\\;', ';'], ['~:', ':'], ['\\:', ':'], ['~`', '`'], ['\\`', '`'], ['~"', '"'], ['\\"', '"'], ['~=', '='], ['\\=', '='], ['~/', '/'], ['\\/', '/'], ['<', '<'], ['\\<', '<'], ['~>', '>'], ['\\>', '>'], ['~&', '&'], ['\\&', '&'], ['!', '!'], ['\\!', '!'], ['~|', '|'], ['\\|', '|'], ['\\t', "\t"], ['\\n', "\n"], ['\\b', "\b"], ['\\f', "\f"], ['\\r', "\r"] ] # Replace all escape sequences in the supplied string and return the new value. 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 end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
modl-0.3.6 | lib/modl/parser/substitutions.rb |
modl-0.3.5 | lib/modl/parser/substitutions.rb |
modl-0.3.4 | lib/modl/parser/substitutions.rb |
modl-0.3.3 | lib/modl/parser/substitutions.rb |