Keith Fahlgren
11/14/2006 10:48:00 PM
On 11/14/06, Chad Burt <chad@underbluewaters.net> wrote:
> Thanks. Found this file: /usr/local/lib/ruby/1.8/net/protocol.rb
> and changed
> ...
> The problem now is that I have a web API client that I was going to
> package into a ruby-gem that would have been easy to install. Now I have
> to tell people to start hacking the standard library if they want to use
> it. Uhhg!
With Ruby's open classes, you shouldn't have to. At the top of your
file/library/program, just open the class you'd like to modify, in
this case the module Net and the class BufferedIO, and do what you
want.
Something like:
module Net
class BufferedIO
def rbuf_fill
timeout(@read_timeout) {
#changed by cburt to a much larger buffer for speed
@rbuf << @io.sysread(16384)
}
end
end
end
Note: Modifying the standard library is usually considered bad form,
but if you know what you're doing and are explicit about it it's
usually ok.
HTH,
Keith