Class: SimpleImagesDownloader::SourceFile
- Inherits:
-
Object
- Object
- SimpleImagesDownloader::SourceFile
- Includes:
- Validatable
- Defined in:
- lib/simple_images_downloader/source_file.rb
Overview
SourceFile class Responsible for opening the file of URLs and validating it
Instance Method Summary collapse
- #each_line {|line| ... } ⇒ Object
-
#initialize(path, validators = [FilePersistanceValidator.new, FileAccessibilityValidator.new]) ⇒ SourceFile
constructor
A new instance of SourceFile.
Methods included from Validatable
Constructor Details
#initialize(path, validators = [FilePersistanceValidator.new, FileAccessibilityValidator.new]) ⇒ SourceFile
Returns a new instance of SourceFile.
17 18 19 20 |
# File 'lib/simple_images_downloader/source_file.rb', line 17 def initialize(path, validators = [FilePersistanceValidator.new, FileAccessibilityValidator.new]) @path = path @validators = validators end |
Instance Method Details
#each_line {|line| ... } ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/simple_images_downloader/source_file.rb', line 24 def each_line(&block) validate!({ path: @path }) begin file.each(chomp: true, &block) ensure file.close end end |