Class: OptParseValidator::OptDirectoryPath

Inherits:
OptPath show all
Defined in:
lib/opt_parse_validator/opts/directory_path.rb

Overview

Implemetantion of the DirectoryPath Option

Instance Attribute Summary

Attributes inherited from OptBase

#attrs, #option, #required

Instance Method Summary collapse

Methods inherited from OptPath

#allowed_attrs, #check_directory, #check_executable, #check_file, #check_readable, #check_writable, #validate

Methods inherited from OptBase

#advanced?, #alias?, #append_help_messages, #choices, #default, #help_message_for_default, #help_messages, #normalize, #required?, #required_unless, #to_long, #to_s, #to_sym, #validate, #value_if_empty

Constructor Details

#initialize(option, attrs = {}) ⇒ OptDirectoryPath

Returns a new instance of OptDirectoryPath.



6
7
8
9
10
# File 'lib/opt_parse_validator/opts/directory_path.rb', line 6

def initialize(option, attrs = {})
  super(option, attrs)

  @attrs.merge!(directory: true)
end

Instance Method Details

#check_create(path) ⇒ Object

Parameters:

  • path (Pathname)


13
14
15
# File 'lib/opt_parse_validator/opts/directory_path.rb', line 13

def check_create(path)
  FileUtils.mkdir_p(path.to_s) unless Dir.exist?(path.to_s)
end