Sha256: c714d8485c2dbe5847f783844d6083824e90b7acc42d499be65b2229d3d76044
Contents?: true
Size: 583 Bytes
Versions: 1
Compression:
Stored size: 583 Bytes
Contents
class Hash # # Bencodes the Hash object. Bencoded hashes are represented as # +dxe+, where +x+ is zero or a power of two bencoded objects. # each key is immediately followed by its associated value. # All keys must be strings. The keys of the bencoded hash will # be in lexicographical order. def bencode pairs = sort.map{|key, val| [key.to_str.bencode, val.bencode] } "d#{pairs.join('')}e" rescue NoMethodError => error if error.name == :to_str raise BEncode::EncodeError, "dictionary keys must be strings" else raise end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bencode-0.5.0 | lib/bencode/encode/hash.rb |