Class: FlickrbCollage::Main
- Inherits:
-
Object
- Object
- FlickrbCollage::Main
- Defined in:
- lib/flickrb_collage/main.rb
Instance Method Summary collapse
- #call ⇒ Object
- #complete_keywords ⇒ Object
- #ensure_extension(filename) ⇒ Object
-
#initialize(keywords = []) ⇒ Main
constructor
A new instance of Main.
Constructor Details
#initialize(keywords = []) ⇒ Main
Returns a new instance of Main.
10 11 12 13 |
# File 'lib/flickrb_collage/main.rb', line 10 def initialize(keywords = []) @keywords = keywords complete_keywords end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/flickrb_collage/main.rb', line 15 def call files = @keywords.map do |keyword| keyword = KeywordSource.new.call until flickr_photo = FlickrPhotoFinder.new(keyword).call url = FlickrPhotoUrl.new(flickr_photo.id).call PhotoDownloader.call(url) end collage = Collage.new(files) collage.build puts "What is the filename? Default is using a timestamp" filename = STDIN.gets.chomp filename.empty? ? collage.create : collage.create(ensure_extension(filename)) end |
#complete_keywords ⇒ Object
29 30 31 |
# File 'lib/flickrb_collage/main.rb', line 29 def complete_keywords @keywords << KeywordSource.new.call while @keywords.size < 10 end |
#ensure_extension(filename) ⇒ Object
33 34 35 36 |
# File 'lib/flickrb_collage/main.rb', line 33 def ensure_extension(filename) array = filename.split('.') "#{array.first}.png" end |