Sha256: 990bb446a1fafd05eb81bb4939b263673de67a0af712c30a56016104b6c071f9
Contents?: true
Size: 517 Bytes
Versions: 2
Compression:
Stored size: 517 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_s.bencode, val.bencode] } "d#{pairs.join}e" rescue NoMethodError => error raise BEncode::EncodeError, "dictionary keys must be strings" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bencode-0.8.0 | lib/bencode/core_ext/hash.rb |
bencode-0.7.0 | lib/bencode/core_ext/hash.rb |