Class: VTools::ConvertOptions
- Inherits:
-
Hash
- Object
- Hash
- VTools::ConvertOptions
- Includes:
- SharedMethods
- Defined in:
- lib/vtools/convert_options.rb
Overview
options for the video converter
Instance Method Summary collapse
-
#[]=(key, value) ⇒ Object
set value method backward compatibility for width height & resolution.
-
#initialize(options = {}, additional = {}) ⇒ ConvertOptions
constructor
A new instance of ConvertOptions.
- #to_s ⇒ Object
Methods included from SharedMethods
Methods included from SharedMethods::Common
#config, #fix_encoding, #generate_path, #hash_to_obj, #json_to_obj, #keys_to_sym, #log, #logger=, #network_call, #parse_json, #path_generator
Constructor Details
#initialize(options = {}, additional = {}) ⇒ ConvertOptions
Returns a new instance of ConvertOptions.
9 10 11 12 13 |
# File 'lib/vtools/convert_options.rb', line 9 def initialize = {}, additional = {} @ignore = [:width, :height, :resolution, :extension, :preserve_aspect, :duration, :postfix] merge! additional parse! end |
Instance Method Details
#[]=(key, value) ⇒ Object
set value method backward compatibility for width height & resolution
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vtools/convert_options.rb', line 17 def []= (key, value) ignore = @ignore[0..2] << :s case # width & height when ignore.first(2).include?(key) ignore.last(2).each { |index| delete(index) } data = { key => value } # resolution when ignore.last(2).include?(key) ignore.each { |index| delete(index) } width, height = value.split("x") data = { :width => width.to_i, :height => height.to_i, :resolution => value, :s => value} # duration when [:duration, :t].include?(key) data = { :duration => value, :t => value } else return super end merge! data return value end |
#to_s ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vtools/convert_options.rb', line 41 def to_s params = collect do |key, value| "-#{key} #{value}" unless @ignore.include?(key) end.compact # put the preset parameters last params = params.reject { |p| p =~ /[avfs]pre/ } + params.select { |p| p =~ /[avfs]pre/ } params.join " " end |