Class: ImageInfo::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/image_info/processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(urls, options = { max_concurrency: ::ImageInfo.config.max_concurrency }) ⇒ Processor

Returns a new instance of Processor.



11
12
13
14
# File 'lib/image_info/processor.rb', line 11

def initialize(urls, options = { max_concurrency: ::ImageInfo.config.max_concurrency })
  @images  = Array(urls).map { |uri| ::ImageInfo::Image.new(uri) }.keep_if(&:valid?)
  @options = options
end

Instance Attribute Details

#imagesObject (readonly)

Returns the value of attribute images.



9
10
11
# File 'lib/image_info/processor.rb', line 9

def images
  @images
end

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/image_info/processor.rb', line 9

def options
  @options
end

Instance Method Details

#processObject



16
17
18
19
20
21
# File 'lib/image_info/processor.rb', line 16

def process
  images.each { |image| hydra.queue(::ImageInfo::RequestHandler.new(image).build) }
  hydra.run

  images
end