Module: Bencoding::Hash
- Defined in:
- lib/bencoding/hash.rb
Instance Method Summary collapse
Instance Method Details
#to_bencoding ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/bencoding/hash.rb', line 5 def to_bencoding return '' if empty? data = sort{|a,b|a[0].to_s<=>b[0].to_s}.collect do|key, item| unless (item_data = item.to_bencoding).nil? key.to_bencoding+item.to_bencoding else '' end end.join "d"+data+"e" end |