Newbie query regarding ruby best practice
- From: "Neowulf" <neowulf@xxxxxxxxxxxx>
- Date: 31 Jan 2006 03:50:53 -0800
Hi all,
I've just finished working on a few util scripts in Ruby to cut my
teeth and I was wondering what the best practice is with regards the
use of class methods.
E.g. Is it better to do something like this...
require 'fileutils'
FileUtils.mv(myfile,newpath)
FileUtils.cp(newpath,anotherpath)
FileUtils.rm(newpath)
or this...
fu = FileUtils.new
fu.mv(myfile,newpath)
fu.cp(newpath,anotherpath)
fu.rm(newpath)
I assume the second would only create a single instance of a
"fileutils" object, thus requiring less overhead than the first?
~Neowulf
.
- Follow-Ups:
- Re: Newbie query regarding ruby best practice
- From: rmagick@xxxxxxxxx
- Re: Newbie query regarding ruby best practice
- Prev by Date: Re: logging with rake
- Next by Date: Re: [ANN] Mongrel HTTP Library 0.2.0 (Fast And RubyForgified)
- Previous by thread: Set#merge
- Next by thread: Re: Newbie query regarding ruby best practice
- Index(es):
Relevant Pages
|