Class: Awaaz::Decoders::BaseDecoder Abstract
- Inherits:
-
Object
- Object
- Awaaz::Decoders::BaseDecoder
- Defined in:
- lib/awaaz/decoders/base_decoder.rb
Overview
Abstract base class for audio decoders in the Awaaz gem.
Provides common configuration handling, option management, and helper methods for working with audio data. Subclasses are expected to implement the #load method to perform the actual decoding process.
Direct Known Subclasses
Class Attribute Summary collapse
-
.available_options ⇒ Array<Symbol>
readonly
The currently available option keys for this decoder class.
Class Method Summary collapse
-
.default_available_options ⇒ Array<Symbol>
The default set of options available to all decoders.
-
.load(filename) ⇒ Object
Loads audio from a given file using this decoder.
-
.set_available_options(provided_available_options = default_available_options) ⇒ void
Sets the list of available options for this decoder class.
Instance Method Summary collapse
-
#available_options ⇒ Array<Symbol>
The available options for this instance.
-
#initialize(filename, **options) ⇒ BaseDecoder
constructor
A new instance of BaseDecoder.
-
#load ⇒ Object
abstract
Loads audio data.
Constructor Details
#initialize(filename, **options) ⇒ BaseDecoder
Returns a new instance of BaseDecoder.
44 45 46 47 |
# File 'lib/awaaz/decoders/base_decoder.rb', line 44 def initialize(filename, **) @filename = filename @options = Utils::SoundConfig.new(, **) end |
Class Attribute Details
.available_options ⇒ Array<Symbol> (readonly)
Returns The currently available option keys for this decoder class.
28 29 30 |
# File 'lib/awaaz/decoders/base_decoder.rb', line 28 def @available_options end |
Class Method Details
.default_available_options ⇒ Array<Symbol>
Returns The default set of options available to all decoders.
15 16 17 |
# File 'lib/awaaz/decoders/base_decoder.rb', line 15 def %i[amplification_factor decoder sample_rate mono] end |
.load(filename) ⇒ Object
Loads audio from a given file using this decoder.
36 37 38 |
# File 'lib/awaaz/decoders/base_decoder.rb', line 36 def load(filename, ...) new(filename, ...).load end |
.set_available_options(provided_available_options = default_available_options) ⇒ void
This method returns an undefined value.
Sets the list of available options for this decoder class.
23 24 25 |
# File 'lib/awaaz/decoders/base_decoder.rb', line 23 def ( = ) @available_options = end |
Instance Method Details
#available_options ⇒ Array<Symbol>
Returns The available options for this instance.
61 62 63 |
# File 'lib/awaaz/decoders/base_decoder.rb', line 61 def self.class. end |
#load ⇒ Object
Loads audio data.
This method must be implemented by subclasses to perform the actual decoding of the file.
56 57 58 |
# File 'lib/awaaz/decoders/base_decoder.rb', line 56 def load raise NotImplementedError end |