Module: Fossyl
- Defined in:
- lib/fossyl.rb
Defined Under Namespace
Classes: Parser
Constant Summary collapse
- InvalidBencoding =
Class.new(StandardError)
Class Method Summary collapse
Class Method Details
.dump(object) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fossyl.rb', line 4 def self.dump(object) case object when String, Symbol "#{object.length}:#{object}" when Integer "i#{object}e" when Array list = object.map {|item| dump(item) }.join "l#{list}e" when Hash hash = object.sort.map {|key, value| dump(key) << dump(value) }.join "d#{hash}e" end end |