README.rdoc in bencodr-1.1.0 vs README.rdoc in bencodr-1.2.0

- old
+ new

@@ -86,20 +86,41 @@ "6:string".bdecode #=> "string" "i1e".bdecode #=> 1 "le".bdecode #=> [] "de".bdecode #=> {} -=== Encoding and Decoding with BEncodr +=== IO and Files +You can also write and read bencodings. + # write to standard out + IO.bencode(1, "string") #=> "6:string" to stdout + $stdout.bencode("string") #=> "6:string" to stdout + + # write to file + File.bencode("a.bencode", "string") #=> "6:string" to a.bencode + + file = File.open("a.bencode", "wb") + file.bencode("string") #=> "6:string" to a.bencode + + # read from standard in + IO.bdecode(0) #=> "string" + $stdin.bdecode #=> "string" + + # read from file + File.bdecode("a.bencode") #=> "string" + + file = File.open("a.bencode", "wb") + file.bdecode #=> "string" + +=== BEncodr +Most of the functionality of this library can also be accessed directly on the BEncodr class. + # encoding is just like calling bencode on the object BEncodr.encode("string") #=> "6:string" # decoding is just like calling bdecode on a bencoding BEncodr.decode("6:string") #=> "string" - BEncodr.decode("i1e") #=> 1 - BEncodr.decode("le") #=> [] - BEncodr.decode("de") #=> {} # you can work directly with files too BEncodr.encode_file("my_awesome.torrent", {:announce => "http://www.sometracker.com/announce:80"}) BEncodr.decode_file("my_awesome.torrent") #=> {:announce => "http://www.sometracker.com/announce:80"} @@ -150,6 +171,6 @@ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) * Send me a pull request. Bonus points for topic branches. == Copyright -Copyright (c) 2010 blatyo. See LICENSE for details. +Copyright (c) 2010 Allen Madsen. See LICENSE for details.