Class: FFmpeg::FilterGraph::Filter

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::Strings

#underscore

Class Method Details

.name(name = nil) ⇒ Object

Parameters:

  • name (String) (defaults to: nil)

    Sets the filter-name output by this filter



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

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



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

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



44
45
46
# File 'lib/ffmpeg/filter_graph/filter.rb', line 44

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



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

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.



39
40
41
# File 'lib/ffmpeg/filter_graph/filter.rb', line 39

def options_string
  join_options(*options.keys)
end

#to_sObject



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

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