module ProperProperties::Encoding

Module to encode and decode

Usage:

encoded = Encoding.encode!("Some text to be encoded")
decoded = Encoding.decode!("Some text to be decoded")

You can disable separate encoding (and decoding) steps, by passing in additional flags:

Constants

SKIP_SEPARATORS

Flag for skipping separators encodings / decoding @return [Symbol]

SKIP_SPECIAL_CHARS

Flag for skipping separators encodings / decoding @return [Symbol]

SKIP_UNICODE

Flag for skipping separators encodings / decoding @return [Symbol]

Public Class Methods

decode!(text, *flags) click to toggle source

Decodes a given text in place @param text [String] @param *flags [Array] Optional flags to skip decoding steps @return [String] The decoded text for chaining

# File lib/proper_properties/encoding.rb, line 48
def self.decode!(text, *flags)
  Unicode.decode!(text)       unless flags.include?(SKIP_UNICODE)
  Separators.decode!(text)    unless flags.include?(SKIP_SEPARATORS)
  SpecialChars.decode!(text)  unless flags.include?(SKIP_SPECIAL_CHARS)
  text
end
encode!(text, *flags) click to toggle source

Encode a given text in place @param text [String] @param *flags [Array] Optional flags to skip encoding steps @return [String] The encoded text for chaining

# File lib/proper_properties/encoding.rb, line 37
def self.encode!(text, *flags)
  SpecialChars.encode!(text)  unless flags.include?(SKIP_SPECIAL_CHARS)
  Separators.encode!(text)    unless flags.include?(SKIP_SEPARATORS)
  Unicode.encode!(text)       unless flags.include?(SKIP_UNICODE)
  text
end