lib/uencode/elements.rb in uencode-0.0.2 vs lib/uencode/elements.rb in uencode-0.0.3

- old
+ new

@@ -26,31 +26,37 @@ } end end module RateElement + ATTRIBUTES = [:numerator, :denominator] + + include AttrSetting + def to_xml %Q{ <#{root_name}> <numerator>#{numerator}</numerator> <denominator>#{denominator}</denominator> </#{root_name}> } end + + def ==(other) + numerator == other.numerator && denominator == other.denominator + end end class FrameRate include RateElement - ATTRIBUTES = [:numerator, :denominator] private def root_name; "framerate"; end end class Par < FrameRate include RateElement - ATTRIBUTES = [:numerator, :denominator] private def root_name; "par"; end end @@ -201,10 +207,20 @@ @deinterlace = false @profile = "main" @passes = 1 @stretch = false end + + def framerate=(_framerate) + _framerate = FrameRate.new(_framerate) unless _framerate.instance_of?(FrameRate) || _framerate.nil? + instance_variable_set :@framerate, _framerate + end + + def par=(_par) + _par = Par.new(_par) unless _par.instance_of?(Par) || _par.nil? + instance_variable_set :@par, _par + end end # The audio configs for each Medium class AudioConfig attr_accessor :codec, :bitrate, :channels, :samplerate @@ -260,7 +276,7 @@ } Nokogiri::XML(xml).to_xml end end - [Size, FrameRate, Crop, VideoOutput, CaptureOutput, Job].each { |klass| klass.send :include, AttrSetting } + [Size, Crop, VideoOutput, CaptureOutput, Job].each { |klass| klass.send :include, AttrSetting } end