Class: Miniatura::Options
- Inherits:
-
Object
- Object
- Miniatura::Options
show all
- Defined in:
- lib/miniatura/options.rb
Constant Summary
collapse
- CLI_KEY =
{
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.
11
12
13
|
# File 'lib/miniatura/options.rb', line 11
def initialize options
@ptions = options
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
42
43
44
|
# File 'lib/miniatura/options.rb', line 42
def method_missing(name, *args)
"#{CLI_KEY[name]} #{args[0]}" if CLI_KEY.has_key? name
end
|
Instance Method Details
#file_extension(value) ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/miniatura/options.rb', line 23
def file_extension value
case value
when 'jpeg' then %Q(-c mjpeg)
when 'png' then %Q(-c png)
else
" "
end
end
|
#rotate(value) ⇒ Object
32
33
34
35
36
37
38
39
40
|
# File 'lib/miniatura/options.rb', line 32
def rotate value
case value
when 90 then %Q(-vf transpose=1)
when 180 then %Q(-vf vflip )
when 270 then %Q(-vf transpose=2)
else
""
end
end
|
#to_options ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/miniatura/options.rb', line 15
def to_options
result = @ptions.map do |k, v|
send(k.to_s, v)
end
result << "-vframes 1"
result.join(' ')
end
|