Class: ImageCollage::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/imagecollage/runner.rb

Constant Summary collapse

COLLAGE_IMAGE_COUNT =
10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keywords, options) ⇒ Runner

Returns a new instance of Runner.



8
9
10
11
# File 'lib/imagecollage/runner.rb', line 8

def initialize(keywords, options)
  @keywords = keywords
  @options = options || {}
end

Instance Attribute Details

#keywordsObject (readonly)

Returns the value of attribute keywords.



4
5
6
# File 'lib/imagecollage/runner.rb', line 4

def keywords
  @keywords
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/imagecollage/runner.rb', line 4

def options
  @options
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
# File 'lib/imagecollage/runner.rb', line 13

def run
  flickr_api = ImageCollage::FlickrApi.new(@options.fetch(:flickr_api_key))
  image_url_requester = ImageUrlRequester.new(@keywords, flickr_api, image_url_count: COLLAGE_IMAGE_COUNT)

  collage_generator = CollageGenerator.new(image_url_requester.image_urls)
  collage_generator.generate_image_collage(@options.fetch(:image_collage_path))

  return 0
end