Robert Klemme
11/20/2003 12:32:00 PM
"T. Onoma" <transami@runbox.com> schrieb im Newsbeitrag
news:E1AMmpA-000682-J5@odie.runbox.com...
> > You are raising an exception, this is, for me, different than sending
> > message to stdout
>
> okay, i grant you that was not the intention of raise when designed. but
a rose by any other name....
>
> so what other means are there? should a raise_message be added? or maybe
you are right. maybe my library is "badly designed", but if so then tell
me what would the alternative be that achieves such seperation?
class Downloader
attr_accessor :state_reporter
def dowload(url)
read_bytes = 0
# open conn
while( chunk = io.read( 1024 ) )
read_bytes += chunk.length
# write bytes to file
self.state_reporter && self.state_reporter.call(url, read_bytes)
end
end
end
d = Downloader.new
d.state_reporter = proc {|url, bytes| puts "read #{bytes} from #{url}"
d.download 'http://foo/bar'
You get the picture...
robert