Class: Hexapic::Collage
- Inherits:
-
Object
- Object
- Hexapic::Collage
- Defined in:
- lib/hexapic/collage.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
3 4 5 |
# File 'lib/hexapic/collage.rb', line 3 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
3 4 5 |
# File 'lib/hexapic/collage.rb', line 3 def width @width end |
Instance Method Details
#make(pictures) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hexapic/collage.rb', line 5 def make(pictures) puts 'Start collage' if pictures.size == 1 Downloader.get pictures.first else images = [] file_path = Downloader.generate_file_path pictures.map.with_index do |picture,index| Thread.new(index) do |i| picture = Downloader.get(picture) if picture.path.nil? images[i] = picture.path end end.each{ |thr| thr.join } puts "Make collage and save to #{file_path}" MiniMagick::Tool::Montage.new do |m| m << '-mode' m << 'concatenate' m << '-tile' m << '3x2' images.each{|img| m << img} m << file_path end puts file_path Repository::Picture.new('','','', file_path) end end |