Class: Imgfetcha::BatchFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/imgfetcha/batch_fetcher.rb

Constant Summary collapse

VALID_TYPES =

NOTE: ‘bin’ stands for ‘application/octet-stream`

%w[jpeg jpg png gif heic bin].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(urls, options) ⇒ BatchFetcher

Returns a new instance of BatchFetcher.



11
12
13
14
15
# File 'lib/imgfetcha/batch_fetcher.rb', line 11

def initialize(urls, options)
  @urls       = urls
  @output_dir = options[:output_dir] || Dir.pwd
  @verbose    = options[:verbose]
end

Instance Attribute Details

#output_dirObject (readonly)

Returns the value of attribute output_dir.



9
10
11
# File 'lib/imgfetcha/batch_fetcher.rb', line 9

def output_dir
  @output_dir
end

#resultObject (readonly)

Returns the value of attribute result.



9
10
11
# File 'lib/imgfetcha/batch_fetcher.rb', line 9

def result
  @result
end

#urlsObject (readonly)

Returns the value of attribute urls.



9
10
11
# File 'lib/imgfetcha/batch_fetcher.rb', line 9

def urls
  @urls
end

Instance Method Details

#runObject



17
18
19
20
21
# File 'lib/imgfetcha/batch_fetcher.rb', line 17

def run
  @result = batch_download
  puts "\nDownloaded #{@result.count} images"
  @result
end