Class: SimpleImagesDownloader::Validatable::DestinationValidator

Inherits:
Validator
  • Object
show all
Defined in:
lib/simple_images_downloader/validatable/destination_validator.rb

Overview

DestinationValidator class Responsible for validating destination path

Examples:

SimpleImagesDownloader::DestinationValidator.new.validate({ path: './images' })

Instance Method Summary collapse

Instance Method Details

#validate(options) ⇒ Object

Parameters:

  • options (Hash)

    hash with path to destination directory

Raises:



15
16
17
18
19
20
# File 'lib/simple_images_downloader/validatable/destination_validator.rb', line 15

def validate(options)
  path = options[:path]

  raise Errors::DestinationIsNotDirectory, path unless File.directory?(path)
  raise Errors::DestinationIsNotWritable, path unless File.writable?(path)
end