Module: BEncode::Integer::Generic::InstanceMethods

Defined in:
lib/bencode/integer.rb

Instance Method Summary collapse

Instance Method Details

#bencode::String

Encodes object into a bencoded integer. BEncoded strings are length-prefixed base ten followed by a colon and the string. Object must implement to_i or to_int.

1.bencode #=> "i1e"

Returns:

  • (::String)

    the bencoded integer



13
14
15
# File 'lib/bencode/integer.rb', line 13

def bencode
  (respond_to?(:to_i) ? to_i : to_int).bencode
end