Class: Optout::File

Inherits:
Object
  • Object
show all
Defined in:
lib/optout.rb

Overview

Optout::File is a validaton rule that can be used to check that an option’s value is a path to a file. By default Optout::File does not check that the file exists. Instead, it checks that the file’s parent directory exists. This is done so that you can validate a path that will be created by the program the options are for. If you do want the file to exist just call the exists method.

Validation rules can be combined:

Optout.options do 
  on :path, "--path", Optout::File.exists.under("/home").named(/\.txt$/)
end

To validate directories use Optout::Dir.

Direct Known Subclasses

Dir

Class Method Summary collapse

Class Method Details

.exists(wanted = true) ⇒ Object

If wanted is true the file must exist.



734
735
736
# File 'lib/optout.rb', line 734

def exists(wanted = true) 
  proxy_for.new.exists(wanted)
end

.proxy_forObject

:nodoc:



738
739
740
# File 'lib/optout.rb', line 738

def proxy_for #:nodoc:
  Validator::File
end