lib/bencode/dictionary.rb in bencode_blatyo-1.0.0 vs lib/bencode/dictionary.rb in bencode_blatyo-1.0.1

- old
+ new

@@ -8,11 +8,11 @@ # alternating keys and their corresponding values followed by an 'e'. Keys appear in sorted order (sorted as raw # strings, not alphanumerics). # # {:cow => "moo", :seven => 7}.bencode #=> "d3:cow3:moo5:seveni7ee" # - # @return [String] the bencoded dictionary + # @return [::String] the bencoded dictionary def bencode (respond_to?(:to_h) ? to_h : to_hash).bencode end end end @@ -41,10 +41,10 @@ # alternating keys and their corresponding values followed by an 'e'. Keys appear in sorted order (sorted as raw # strings, not alphanumerics). # # {:cow => "moo", :seven => 7}.bencode #=> "d3:cow3:moo5:seveni7ee" # - # @return [String] the bencoded dictionary + # @return [::String] the bencoded dictionary def bencode keys.sort{|a, b| a.to_s <=> b.to_s}.collect do |key| key.to_s.bencode + self[key].bencode end.unshift(:d).push(:e).join end \ No newline at end of file