lib/java-properties/encoding/special_chars.rb in java-properties-0.0.2 vs lib/java-properties/encoding/special_chars.rb in java-properties-0.1.0
- old
+ new
@@ -1,8 +1,9 @@
module JavaProperties
module Encoding
# Module to escape and unescape special chars
+ # @see JavaProperties::Encoding
module SpecialChars
# Lookup table for escaping special chars
# @return [Hash]
ESCAPING = {
@@ -20,11 +21,11 @@
# @return [Regexp]
DESCAPING_MARKER = /\\./
# Encodes the content a text by escaping all special chars
# @param text [String]
- # @return [String]
+ # @return [String] The escaped text for chaining
def self.encode!(text)
buffer = StringIO.new
text.each_char do |char|
buffer << ESCAPING.fetch(char, char)
end
@@ -32,10 +33,10 @@
text
end
# Decodes the content a text by removing all escaping from special chars
# @param text [String]
- # @return [String]
+ # @return [String] The unescaped text for chaining
def self.decode!(text)
text.gsub!(DESCAPING_MARKER) do |match|
DESCAPING.fetch(match, match)
end
text
\ No newline at end of file