Class: Scissor::SoundFile

Inherits:
Object
  • Object
show all
Defined in:
lib/scissor/sound_file.rb

Direct Known Subclasses

M4a, Mp3, Wav

Defined Under Namespace

Classes: Error, M4a, Mp3, UnknownFormat, Wav

Constant Summary collapse

SUPPORTED_FORMATS =
{
  :mp3 => Mp3,
  :wav => Wav,
  :m4a => M4a
}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ SoundFile

Returns a new instance of SoundFile.



84
85
86
# File 'lib/scissor/sound_file.rb', line 84

def initialize(filename)
  @filename = Pathname.new(filename)
end

Class Method Details

.new_from_filename(filename) ⇒ Object



74
75
76
77
78
79
80
81
82
# File 'lib/scissor/sound_file.rb', line 74

def self.new_from_filename(filename)
  ext = filename.extname.sub(/^\./, '').downcase

  unless klass = SUPPORTED_FORMATS[ext.to_sym]
    raise UnknownFormat
  end

  klass.new(filename)
end