Module: Ethon::Easy::Util Private

Extended by:
Util
Included in:
Form, Params, Util
Defined in:
lib/ethon/easy/util.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

This module contains small helpers.

Instance Method Summary collapse

Instance Method Details

#escape_zero_byte(value) ⇒ String, Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Escapes zero bytes in strings.

Examples:

Escape zero bytes.

Util.escape_zero_byte("1\0")
#=> "1\\0"

Parameters:

  • value (Object)

    The value to escape.

Returns:

  • (String, Object)

    Escaped String if zero byte found, original object if not.


19
20
21
22
# File 'lib/ethon/easy/util.rb', line 19

def escape_zero_byte(value)
  return value unless value.to_s.include?(0.chr)
  value.to_s.gsub(0.chr, '\\\0')
end