Module: SimpleImagesDownloader

Defined in:
lib/simple_images_downloader.rb,
lib/simple_images_downloader/line.rb,
lib/simple_images_downloader/client.rb,
lib/simple_images_downloader/errors.rb,
lib/simple_images_downloader/runner.rb,
lib/simple_images_downloader/version.rb,
lib/simple_images_downloader/dispenser.rb,
lib/simple_images_downloader/downloader.rb,
lib/simple_images_downloader/source_file.rb,
lib/simple_images_downloader/validatable.rb,
lib/simple_images_downloader/configuration.rb,
lib/simple_images_downloader/strategies/strategy.rb,
lib/simple_images_downloader/stringio_to_tempfile.rb,
lib/simple_images_downloader/validatable/validator.rb,
lib/simple_images_downloader/strategies/from_url_strategy.rb,
lib/simple_images_downloader/strategies/from_file_strategy.rb,
lib/simple_images_downloader/validatable/mime_type_validator.rb,
lib/simple_images_downloader/validatable/destination_validator.rb,
lib/simple_images_downloader/validatable/file_persistance_validator.rb,
lib/simple_images_downloader/validatable/file_accessibility_validator.rb

Overview

SimpleImagesDownloader module It is a main module of the gem It is responsible for providing interface to download images from file or url

Examples:

SimpleImagesDownloader.from_file('./urls.txt')
SimpleImagesDownloader.from_url('https://example.com/image.jpg')

Defined Under Namespace

Modules: Errors, Strategies, StringioToTempfile, Validatable Classes: Client, Configuration, Dispenser, Downloader, Line, Runner, SourceFile

Constant Summary collapse

VERSION =

gem version

'1.1.1'

Class Method Summary collapse

Class Method Details

.from_file(path) ⇒ Object

Downloads images from file by taking urls from it. Places images to the destination folder set in configuration

Parameters:

  • path (String)

    path to file with urls



40
41
42
# File 'lib/simple_images_downloader.rb', line 40

def self.from_file(path)
  SimpleImagesDownloader::Strategies::FromFileStrategy.new(path).process
end

.from_url(url) ⇒ Object

Downloads image from url. Places image to the destination folder set in configuration

Parameters:

  • url (String)

    url of image



47
48
49
# File 'lib/simple_images_downloader.rb', line 47

def self.from_url(url)
  SimpleImagesDownloader::Strategies::FromUrlStrategy.new(url).process
end

.rootString

Returns root path of the gem. It is used for testing purposes

Returns:

  • (String)

    root path of the gem



53
54
55
# File 'lib/simple_images_downloader.rb', line 53

def self.root
  File.dirname __dir__
end