Forum: Ruby FileUtlis class options

249c7fd851c5c5ac5a1abdb756472ae1?d=identicon&s=25 Arup Rakshit (my-ruby)
on 2013-11-09 14:39
I am confused with the actual use cases of the options

- :force
- :noop
- :verbose

Basically I was reading and trying some methods in the FileUtlis class
today and some examples here
http://www.ruby-doc.org/stdlib-2.0.0/libdoc/fileut...

made me confused... I am trying to understand why and when should anyone
consider to use such options with the method?

FileUtils.mv Dir.glob('test*.rb'), 'test', :noop => true, :verbose =>
true

FileUtils.mv Dir.glob('test*.rb'), 'test', :noop => true

FileUtils.mv Dir.glob('test*.rb'), 'test', :verbose => true

What are the differences between these 3 lines ?
Aa082c8b00a50928e5860dcd70bf2368?d=identicon&s=25 tamouse m. (tamouse_m)
on 2013-11-10 00:28
(Received via mailing list)
On Nov 9, 2013, at 7:39 AM, Love U Ruby <lists@ruby-forum.com> wrote:

> made me confused... I am trying to understand why and when should anyone
> consider to use such options with the method?
>
> FileUtils.mv Dir.glob('test*.rb'), 'test', :noop => true, :verbose =>
> true
>
> FileUtils.mv Dir.glob('test*.rb'), 'test', :noop => true
>
> FileUtils.mv Dir.glob('test*.rb'), 'test', :verbose => true
>
> What are the differences between these 3 lines ?

:noop means "take no action"  consider it a dry run to see what would
happen.
:verbose means "say what you are doing (or would do)"

Why someone would use :noop is possibly a matter of speculation, but
having a dry run option to see what something will attempt to do before
actually doing it can be of some value. Consider if instead of hard
coding it to true or false, it was set by a variable in the script,
perhaps by something set on a command line.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.