Class: PopulateMe::Variation
- Inherits:
-
Struct
- Object
- Struct
- PopulateMe::Variation
- Defined in:
- lib/populate_me/variation.rb
Instance Attribute Summary collapse
-
#ext ⇒ Object
Returns the value of attribute ext.
-
#job ⇒ Object
Returns the value of attribute job.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, ext, job_as_proc = nil, &job_as_block) ⇒ Variation
constructor
Simple class to deal with variations of an attachment Mainly variation of images using ImageMagick but it could be anything else like creating the pdf version of a text file.
Constructor Details
#initialize(name, ext, job_as_proc = nil, &job_as_block) ⇒ Variation
Simple class to deal with variations of an attachment Mainly variation of images using ImageMagick but it could be anything else like creating the pdf version of a text file
10 11 12 |
# File 'lib/populate_me/variation.rb', line 10 def initialize name, ext, job_as_proc=nil, &job_as_block super name, ext, job_as_proc||job_as_block end |
Instance Attribute Details
#ext ⇒ Object
Returns the value of attribute ext
3 4 5 |
# File 'lib/populate_me/variation.rb', line 3 def ext @ext end |
#job ⇒ Object
Returns the value of attribute job
3 4 5 |
# File 'lib/populate_me/variation.rb', line 3 def job @job end |
#name ⇒ Object
Returns the value of attribute name
3 4 5 |
# File 'lib/populate_me/variation.rb', line 3 def name @name end |
Class Method Details
.default ⇒ Object
29 30 31 |
# File 'lib/populate_me/variation.rb', line 29 def default self.new_image_magick_job(:populate_me_thumb, :jpg, "-flatten -resize '400x230' -gravity center -extent 400x230") end |
.new_image_magick_job(name, ext, convert_string, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/populate_me/variation.rb', line 16 def new_image_magick_job name, ext, convert_string, ={} o = { strip: true, progressive: true, }.merge() defaults = "" defaults << "-strip " if o[:strip] defaults << "-interlace Plane " if o[:progressive] and [:jpg,:jpeg].include?(ext.to_sym) job = lambda{ |src,dst| Kernel.system "convert \"#{src}\" #{defaults}#{convert_string} \"#{dst}\"" } self.new name, ext, job end |