FileUtlis class options

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/fileutils/rdoc/FileUtils.html#method-c-mv

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 ?

On Nov 9, 2013, at 7:39 AM, Love U Ruby [email protected] 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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs