Class: Miniatura::Options
- Inherits:
-
Object
- Object
- Miniatura::Options
show all
- 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
Constructor Details
#initialize(options) ⇒ Options
Returns a new instance of Options.
12
13
14
|
# File 'lib/miniatura/options.rb', line 12
def initialize(options)
@options = options
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
46
47
48
|
# File 'lib/miniatura/options.rb', line 46
def method_missing(name, *args)
"#{CLI_KEY[name]} #{args[0]}" if CLI_KEY.has_key? name
end
|
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 to_options
result = @options.map { |k, v| send(k.to_s, v) }
result << '-vframes 1'
result.join(' ')
end
|