Class: ImageGenie::Convert
- Inherits:
-
Command
- Object
- Command
- ImageGenie::Convert
- Defined in:
- lib/image_genie/convert.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#src ⇒ Object
Returns the value of attribute src.
-
#src_format ⇒ Object
Returns the value of attribute src_format.
-
#temp_image_file ⇒ Object
Returns the value of attribute temp_image_file.
Instance Method Summary collapse
-
#initialize(src, options = {}) ⇒ Convert
constructor
A new instance of Convert.
- #output ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(src, options = {}) ⇒ Convert
Returns a new instance of Convert.
13 14 15 16 17 18 19 20 21 |
# File 'lib/image_genie/convert.rb', line 13 def initialize(src,={}) self.src = src self. = self.src_format = File.extname(src.path).downcase.gsub(/\.|\?/,'') logger.info("#{self.class.name} Attempting to convert #{src.path}") raise Errno::ENOENT,"#{src.path}" unless File.exists?(src.path) self.temp_image_file = Tempfile.new([src.original_filename,".#{src_format}"]) super(self) end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/image_genie/convert.rb', line 4 def @options end |
#src ⇒ Object
Returns the value of attribute src.
4 5 6 |
# File 'lib/image_genie/convert.rb', line 4 def src @src end |
#src_format ⇒ Object
Returns the value of attribute src_format.
4 5 6 |
# File 'lib/image_genie/convert.rb', line 4 def src_format @src_format end |
#temp_image_file ⇒ Object
Returns the value of attribute temp_image_file.
4 5 6 |
# File 'lib/image_genie/convert.rb', line 4 def temp_image_file @temp_image_file end |
Instance Method Details
#output ⇒ Object
6 7 8 9 10 11 |
# File 'lib/image_genie/convert.rb', line 6 def output while line = stdout.gets temp_image_file.puts line end temp_image_file.rewind end |
#run ⇒ Object
23 24 25 26 |
# File 'lib/image_genie/convert.rb', line 23 def run execute("#{path_for(:convert)} #{make_flags()} #{src_format}:#{src.path} #{src_format}:-") temp_image_file end |