Class: Miniatura::Options
- Inherits:
-
Object
- Object
- Miniatura::Options
- Defined in:
- lib/miniatura/options.rb
Constant Summary collapse
- CLI_KEY =
Options class to add various options to the ffmpeg command generated.
{ size: '-s', time_frame: '-ss', quality: '-q', file_extension: '-c' }
Instance Method Summary collapse
- #file_extension(value) ⇒ Object
-
#initialize(options) ⇒ Options
constructor
A new instance of Options.
- #method_missing(name, *args) ⇒ Object
- #rotate(value) ⇒ Object
- #to_options ⇒ Object
Constructor Details
#initialize(options) ⇒ Options
Returns a new instance of Options.
12 13 14 |
# File 'lib/miniatura/options.rb', line 12 def initialize() @options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
Instance Method Details
#file_extension(value) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/miniatura/options.rb', line 22 def file_extension(value) case value when 'jpeg' '-c mjpeg' when 'png' '-c png' else '' end end |
#rotate(value) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/miniatura/options.rb', line 33 def rotate(value) case value when 90 '-vf transpose=1' when 180 '-vf hflip ' when 270 '-vf transpose=2' else '' end end |
#to_options ⇒ Object
16 17 18 19 20 |
# File 'lib/miniatura/options.rb', line 16 def result = @options.map { |k, v| send(k.to_s, v) } result << '-vframes 1' result.join(' ') end |