Module: BEncode::String::String::InstanceMethods

Defined in:
lib/bencode/string.rb

Instance Method Summary collapse

Instance Method Details

#bencode::String

Encodes a string into a bencoded string. BEncoded strings are length-prefixed base ten followed by a colon and the string.

"string".bencode #=> "6:string"

Returns:

  • (::String)

    the bencoded string



50
51
52
# File 'lib/bencode/string.rb', line 50

def bencode
  [length, ':', self].join
end