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
48
49
50
|
# File 'lib/miniatura/options.rb', line 48
def method_missing(name, *args)
"#{CLI_KEY[name]} #{args[0]}" if CLI_KEY.has_key? name
end
|
Instance Method Details
#file_extension(value) ⇒ Object
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/miniatura/options.rb', line 24
def file_extension(value)
case value
when 'jpeg' then
'-c mjpeg'
when 'png' then
'-c png'
else
''
end
end
|
#rotate(value) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/miniatura/options.rb', line 35
def rotate(value)
case value
when 90 then
'-vf transpose=1'
when 180 then
'-vf hflip '
when 270 then
'-vf transpose=2'
else
''
end
end
|
#to_options ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/miniatura/options.rb', line 16
def to_options
result = @options.map do |k, v|
send(k.to_s, v)
end
result << '-vframes 1'
result.join(' ')
end
|