Sha256: c4c65d48207ff2a6222fb391e8f2fb6799525bec20bbee7010a4db7c9705054d
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
require 'defaults' module WordsToImage class Processor def initialize(local_settings={}) @images_count = local_settings[:images_count] || DEFAULT_SETTINGS[:images_count] @dictionary_path = local_settings[:dictionary_path] || DEFAULT_SETTINGS[:dictionary_path] @result_path = local_settings[:result_path] || DEFAULT_SETTINGS[:result_path] @max_row_width = [local_settings[:max_row_width] || DEFAULT_SETTINGS[:max_row_width], 150].max @images, @words = [], [] @dictionary = Dictionary.new(@dictionary_path) end def get_images(keywords=[]) while !collection_complete? keyword = keywords.shift || @dictionary.get_word raise ArgumentError, "not enough words to complete a collage" unless keyword next unless image = Flickr.fetch( keyword ) @images << image @words << keyword end end def create_collage @result = Collage.new(@result_path, @max_row_width, @images.count) @images.each do |path| image = Image.new(path).download.squarize! @result += image image.delete! end end private def collection_complete? @images.count == @images_count end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
words_to_image-0.0.2 | lib/words_to_image/processor.rb |