Class: R2mp3::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/r2mp3/converter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options={})
  @input_file = options[:in]
  @output_file = options[:out]
  @wav_output = options[:wav].nil? ? "audiodump.wav" : options[:wav]
  @mode = options[:mode]
  @bitrate = options[:bitrate]
end

Instance Attribute Details

#default_recipeObject (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_pathObject (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

Returns:

  • (Boolean)


28
29
30
# File 'lib/r2mp3/converter.rb', line 28

def is_mp3?
  @mp3
end

#is_wav?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/r2mp3/converter.rb', line 24

def is_wav?
  @wav
end

#to_mp3Object



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