Class: SimpleImagesDownloader::Strategies::FromFileStrategy

Inherits:
Strategy
  • Object
show all
Defined in:
lib/simple_images_downloader/strategies/from_file_strategy.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FromFileStrategy

Returns a new instance of FromFileStrategy.



6
7
8
9
# File 'lib/simple_images_downloader/strategies/from_file_strategy.rb', line 6

def initialize(path)
  super
  @path = path
end

Instance Method Details

#processObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/simple_images_downloader/strategies/from_file_strategy.rb', line 11

def process
  source_file = SourceFile.new(@path)

  source_file.each_line do |line|
    uri = Line.new(line).uri
    Downloader.new(uri).download
  rescue Errors::BaseError => e
    puts e.message
    next
  end
end