Sha256: f217155894895fe7ba24d51ffc87bfa1c3bb19c235556dc54de9e6ac16c6009d
Contents?: true
Size: 508 Bytes
Versions: 3
Compression:
Stored size: 508 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 raise BEncode::EncodeError, "dictionary keys must be strings" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bencode-1.0.0 | lib/bencode/core_ext/hash.rb |
bencode-0.8.2 | lib/bencode/core_ext/hash.rb |
bencode-0.8.1 | lib/bencode/core_ext/hash.rb |