Module: CarrierWave::AudioWaveform

Defined in:
lib/carrierwave/audio_waveform.rb,
lib/carrierwave/audio_waveform/version.rb,
lib/carrierwave/audio_waveform/waveformer.rb,
lib/carrierwave/audio_waveform/waveform_data.rb

Defined Under Namespace

Modules: ClassMethods Classes: WaveformData, Waveformer

Constant Summary collapse

VERSION =
'1.0.6'

Instance Method Summary collapse

Instance Method Details

#waveform(options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/carrierwave/audio_waveform.rb', line 19

def waveform options={}
  cache_stored_file! if !cached?

  image_filename = Waveformer.generate(current_path, options)
  File.rename image_filename, current_path

  if options[:type] == :svg
    self.file.instance_variable_set(:@content_type, "image/svg+xml")
  else
    self.file.instance_variable_set(:@content_type, "image/png")
  end
end

#waveform_data(options = {}) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/carrierwave/audio_waveform.rb', line 32

def waveform_data options={}
  cache_stored_file! if !cached?

  data_filename = WaveformData.generate(current_path, options)
  File.rename data_filename, current_path
  self.file.instance_variable_set(:@content_type, "application/json")
end