Class: FFmpeg::FilterGraph::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/ffmpeg/filter_graph/filter.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.name(name = nil) ⇒ Object

Parameters:

  • name (String) (defaults to: nil)

    Sets the filter-name output by this filter



5
6
7
8
9
10
11
# File 'lib/ffmpeg/filter_graph/filter.rb', line 5

def name(name = nil)
  if name.nil?
    @name || fail('filter name not set')
  else
    @name = name
  end
end

.option(*opts) ⇒ Object Also known as: options

Parameters:

  • opts (Array<String>)

    a list of valid options for this filter



14
15
16
17
18
19
20
21
22
23
# File 'lib/ffmpeg/filter_graph/filter.rb', line 14

def option(*opts)
  @opts ||= []

  if opts.any?
    @opts.concat(opts)
    attr_accessor *opts
  end

  @opts
end

Instance Method Details

#empty!Object

Set all options to nil



42
43
44
# File 'lib/ffmpeg/filter_graph/filter.rb', line 42

def empty!
  self.class.options.each { |opt| send("#{opt}=", nil) }
end

#optionsHash<String,String>

values will not be included.

Returns:

  • (Hash<String,String>)

    a map of all options and their values. nil



48
49
50
51
52
53
54
55
56
# File 'lib/ffmpeg/filter_graph/filter.rb', line 48

def options
  ret = {}
  self.class.options.each do |opt|
    if (val = self.send(opt))
      ret[opt] = val
    end
  end
  ret
end

#options_stringString

Note:

May be overridden by atypical filters

Returns A string concatenating the set options.

Returns:

  • (String)

    A string concatenating the set options.



37
38
39
# File 'lib/ffmpeg/filter_graph/filter.rb', line 37

def options_string
  join_options(*options.keys)
end

#to_sObject



27
28
29
30
31
32
33
# File 'lib/ffmpeg/filter_graph/filter.rb', line 27

def to_s
  if options.any?
    "#{self.class.name}=#{options_string}"
  else
    self.class.name
  end
end