Decodes str into a Ruby structure.
str
Parameters:
a bencoded string
a customizable set of options
Options Hash (opts):
whether to ignore invalid bencode at the end of str
Returns:
a Ruby object
Raises:
if str is malformed
21 22 23 24 25 26
# File 'lib/bencode/decode.rb', line 21 def self.load(str, opts = {}) scanner = BEncode::Parser.new(str) obj = scanner.parse! raise BEncode::DecodeError unless (opts[:ignore_trailing_junk] || scanner.eos?) obj end