lib/bencodr/object.rb in bencodr-2.0.1 vs lib/bencodr/object.rb in bencodr-3.0.0
- old
+ new
@@ -1,5 +1,7 @@
+# encoding: UTF-8
+
module BEncodr
module Object
def self.bencode(object)
return object.bencode if object.respond_to?(:bencode)
@@ -23,10 +25,11 @@
raise BEncodeError, "BEncodr::Object.bencode was unable to infer the type of the object passed in."
end
def self.bdecode(string)
- object = Parser.parse_object(StringScanner.new(string))
+ scanner = StringScanner.new(string)
+ object = Parser.parse_object(scanner)
object or raise BEncodeError, "BEncodr::Object.bdecode was unable to parse the string passed in."
end
def bdecode
Object.bdecode(self)
\ No newline at end of file