Method: TNetstring.encode

Defined in:
lib/tnetstring.rb

.encode(obj) ⇒ Object

DEPRECATED: Please use dump instead.

Constructs a tnetstring out of the given object. Valid Ruby object types include strings, integers, boolean values, nil, arrays, and hashes. Arrays and hashes may contain any of the previous valid Ruby object types, but hash keys must be strings.

Example

int = 12345
TNetstring.dump(int)

#=> '5:12345#'

hash = {'hello' => 'world'}
TNetstring.dump(hash)

#=> '16:5:hello,5:world,}'

124
125
126
127
# File 'lib/tnetstring.rb', line 124

def self.encode(obj)
  warn "[DEPRECATION] `encode` is deprecated.  Please use `dump` instead."
  dump obj
end