Class: FFmpeg::FilterGraph::FilterFactory
- Inherits:
-
Object
- Object
- FFmpeg::FilterGraph::FilterFactory
- Includes:
- Utils::Strings
- Defined in:
- lib/ffmpeg/filter_graph/filter_factory.rb
Overview
This factory creates a new [Filter] subclass. The filters are all very silimar, so it’s easier to generate each class than to write them by hand.
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#editable ⇒ Object
Returns the value of attribute editable.
-
#optional ⇒ Object
Returns the value of attribute optional.
-
#options_string ⇒ Object
Returns the value of attribute options_string.
-
#required ⇒ Object
Returns the value of attribute required.
Class Method Summary collapse
Instance Method Summary collapse
-
#create_class_in(mod, helper_module: Helper) ⇒ Object
in.
-
#initialize(class_name, required, optional, editable, &options_string) ⇒ FilterFactory
constructor
A new instance of FilterFactory.
Methods included from Utils::Strings
Constructor Details
#initialize(class_name, required, optional, editable, &options_string) ⇒ FilterFactory
Returns a new instance of FilterFactory.
29 30 31 32 33 34 35 |
# File 'lib/ffmpeg/filter_graph/filter_factory.rb', line 29 def initialize(class_name, required, optional, editable, &) self.class_name = class_name.to_s self.required = required || [] self.optional = optional || [] self.editable = editable self. = end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
7 8 9 |
# File 'lib/ffmpeg/filter_graph/filter_factory.rb', line 7 def class_name @class_name end |
#editable ⇒ Object
Returns the value of attribute editable.
7 8 9 |
# File 'lib/ffmpeg/filter_graph/filter_factory.rb', line 7 def editable @editable end |
#optional ⇒ Object
Returns the value of attribute optional.
7 8 9 |
# File 'lib/ffmpeg/filter_graph/filter_factory.rb', line 7 def optional @optional end |
#options_string ⇒ Object
Returns the value of attribute options_string.
7 8 9 |
# File 'lib/ffmpeg/filter_graph/filter_factory.rb', line 7 def @options_string end |
#required ⇒ Object
Returns the value of attribute required.
7 8 9 |
# File 'lib/ffmpeg/filter_graph/filter_factory.rb', line 7 def required @required end |
Class Method Details
.create(name, opts) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/ffmpeg/filter_graph/filter_factory.rb', line 9 def self.create(name, opts) new( name, opts[:required], opts[:optional], opts[:editable], &opts[:options_string] ) end |
Instance Method Details
#create_class_in(mod, helper_module: Helper) ⇒ Object
in. ex: if the filter class is named MyFilter, a method will be created in the form of Helper.my_filter(*args); MyFilter.new(*args) end
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ffmpeg/filter_graph/filter_factory.rb', line 41 def create_class_in(mod, helper_module: Helper) # We need to make these local vars, to work in the Class.new block cn = class_name.to_s klass = create_class(cn, required, optional, editable, ) mod.const_set(cn, klass) if helper_module helper_name = underscore(cn) helper_module.module_exec do klass = mod.const_get(cn) define_method(helper_name) { |*args| klass.new(*args) } end end end |