Class: R2mp3::Converter
- Inherits:
-
Object
- Object
- R2mp3::Converter
- Defined in:
- lib/r2mp3/converter.rb
Instance Attribute Summary collapse
-
#default_recipe ⇒ Object
readonly
Returns the value of attribute default_recipe.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Converter
constructor
A new instance of Converter.
- #is_mp3? ⇒ Boolean
- #is_wav? ⇒ Boolean
- #to_mp3 ⇒ Object
- #to_mp3! ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Converter
Returns a new instance of Converter.
5 6 7 8 9 10 11 |
# File 'lib/r2mp3/converter.rb', line 5 def initialize(={}) @input_file = [:in] @output_file = [:out] @wav_output = [:wav].nil? ? "audiodump.wav" : [:wav] @mode = [:mode] @bitrate = [:bitrate] end |
Instance Attribute Details
#default_recipe ⇒ Object (readonly)
Returns the value of attribute default_recipe.
3 4 5 |
# File 'lib/r2mp3/converter.rb', line 3 def default_recipe @default_recipe end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
3 4 5 |
# File 'lib/r2mp3/converter.rb', line 3 def output_path @output_path end |
Instance Method Details
#is_mp3? ⇒ Boolean
28 29 30 |
# File 'lib/r2mp3/converter.rb', line 28 def is_mp3? @mp3 end |
#is_wav? ⇒ Boolean
24 25 26 |
# File 'lib/r2mp3/converter.rb', line 24 def is_wav? @wav end |
#to_mp3 ⇒ Object
13 14 15 16 |
# File 'lib/r2mp3/converter.rb', line 13 def to_mp3 return false unless convert_from_to(:file => @input_file, :from => audio_info.type, :to => :wav) convert_from_to(:file => @input_file, :from => :wav, :to => :mp3) end |
#to_mp3! ⇒ Object
18 19 20 21 22 |
# File 'lib/r2mp3/converter.rb', line 18 def to_mp3! raise ConverterError::DumpToWaveError unless convert_from_to(:file => @input_file, :from => audio_info.type, :to => :wav) raise ConverterError::CovertToMp3Error unless convert_from_to(:file => @input_file, :from => :wav, :to => :mp3) return true end |