Sha256: 5777e9c5f971e22263fdaab4f83a2c9f7e5c85b4e8d7a5edb761da1bbd9ac620

Contents?: true

Size: 311 Bytes

Versions: 7

Compression:

Stored size: 311 Bytes

Contents

class String
  #
  # Bencodes the String object. Bencoded strings are represented
  # as <code>x</code>:<code>y</code>, where +y+ is the string and +x+ 
  # is the length of the string.
  #   
  #   "foo".bencode   #=> "3:foo"
  #   "".bencode      #=> "0:"
  #
  def bencode
    "#{length}:#{self}"
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
dasch-bencode-0.5.0 lib/bencode/encode/string.rb
mikehodgson-bencode-0.5.0 lib/bencode/encode/string.rb
bencode-0.8.0 lib/bencode/core_ext/string.rb
bencode-0.7.0 lib/bencode/core_ext/string.rb
bencode-0.6.0 lib/bencode/encode/string.rb
bencode-0.5.1 lib/bencode/encode/string.rb
bencode-0.5.0 lib/bencode/encode/string.rb