Method: CompactData::Parser.replace_escapes

Defined in:
lib/compactdata/parser/parser.rb

.replace_escapes(str) ⇒ Object



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/compactdata/parser/parser.rb', line 271

def self.replace_escapes(str)
  return str unless str.instance_of?(String)

  result = str
  i = 0
  while i < str.length
    REPLACEMENTS.each_pair do |key, value|
      if result.slice(i..).start_with?(key)
        result = result.sub(key, value)
        break
      end
    end
    i += 1
  end
  result
end