Module: JavaProperties::Encoding

Defined in:
lib/java-properties/encoding.rb,
lib/java-properties/encoding/unicode.rb,
lib/java-properties/encoding/separators.rb,
lib/java-properties/encoding/special_chars.rb

Overview

Module to encode and decode

Defined Under Namespace

Modules: Separators, SpecialChars, Unicode

Constant Summary collapse

SKIP_SEPARATORS =

Flag for skipping separators encodings / decoding

Returns:

  • (Symbol)
:skip_separators
SKIP_UNICODE =

Flag for skipping separators encodings / decoding

Returns:

  • (Symbol)
:skip_unicode
SKIP_SPECIAL_CHARS =

Flag for skipping separators encodings / decoding

Returns:

  • (Symbol)
:skip_special_chars

Class Method Summary collapse

Class Method Details

.decode!(text, *flags) ⇒ String

Decodes a given text in place

Parameters:

  • text (String)
  • flags (Symbol)

    Optional flags to skip decoding steps

Returns:

  • (String)


36
37
38
39
40
41
# File 'lib/java-properties/encoding.rb', line 36

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) ⇒ String

Encode a given text in place

Parameters:

  • text (String)
  • flags (Symbol)

    Optional flags to skip encoding steps

Returns:

  • (String)


25
26
27
28
29
30
# File 'lib/java-properties/encoding.rb', line 25

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