From: Rob Biedenharn Date: 2007-03-25T21:59:37+09:00 Subject: Re: Read only a few bytes from file On Mar 25, 2007, at 7:10 AM, toulax@gmail.com wrote: > Is there any way to read only a determined amount of bytes from a > specific file? I actually want to do that to a URL, but I assume the > procedure would be the same. > > If someone could at least point me to the right direction that would > be great! > > Thanks Initial contents of http://conferences.oreillynet.com/rails/ RailsConf 2007 • May 17, 2007 - May 20, 2007 • Portland, Oregon $ irb >> require 'open-uri' => true >> open('http://conferences.oreillynet.com/rails/') { |f| ?> f.pos = 182 >> puts f.read(14) >> } RailsConf 2007 => nil open-uri extends Kernel#open to understand how to read from HTTP and FTP sources IO#pos= sets the offset IO#read returns up to the number of bytes requested -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com