Forum: Ruby FileUtlis class options

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
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.
This topic is locked and can not be replied to.