Class: Awaaz::Config
- Inherits:
-
Object
- Object
- Awaaz::Config
- Defined in:
- lib/awaaz/config.rb
Overview
The Config class handles detection and configuration of available audio decoders for the Awaaz gem. It checks the system for supported decoder binaries (mpg123, ffmpeg, sox) and provides query helpers to check their availability.
Instance Method Summary collapse
-
#decoder?(name) ⇒ Boolean
Checks if a given decoder is available on the system.
-
#decoders_for_wav? ⇒ Boolean
Checks if there is at least one decoder capable of handling WAV files.
-
#ffmpeg? ⇒ Boolean
Checks if ffmpeg is available.
-
#initialize ⇒ Config
constructor
Creates a new configuration instance and detects available decoders.
-
#mpg123? ⇒ Boolean
Checks if mpg123 is available.
-
#no_decoders? ⇒ Boolean
Checks if no decoders are available on the system.
-
#no_decoders_for_wav? ⇒ Boolean
Checks if there are no decoders available for handling WAV files.
-
#potential_decoders ⇒ Array<Symbol>
Lists all potential decoders that Awaaz can work with.
-
#sox? ⇒ Boolean
Checks if sox is available.
Constructor Details
#initialize ⇒ Config
Creates a new configuration instance and detects available decoders.
20 21 22 |
# File 'lib/awaaz/config.rb', line 20 def initialize @available_decoders = detect_decoders end |
Instance Method Details
#decoder?(name) ⇒ Boolean
Checks if a given decoder is available on the system.
30 31 32 |
# File 'lib/awaaz/config.rb', line 30 def decoder?(name) @available_decoders.include?(name.to_sym) end |
#decoders_for_wav? ⇒ Boolean
Checks if there is at least one decoder capable of handling WAV files.
Currently, ‘ffmpeg` and `sox` are considered capable of decoding WAV files.
86 87 88 |
# File 'lib/awaaz/config.rb', line 86 def decoders_for_wav? ffmpeg? || sox? end |
#ffmpeg? ⇒ Boolean
Checks if ffmpeg is available.
48 49 50 |
# File 'lib/awaaz/config.rb', line 48 def ffmpeg? decoder?(:ffmpeg) end |
#mpg123? ⇒ Boolean
Checks if mpg123 is available.
39 40 41 |
# File 'lib/awaaz/config.rb', line 39 def mpg123? decoder?(:mpg123) end |
#no_decoders? ⇒ Boolean
Checks if no decoders are available on the system.
75 76 77 |
# File 'lib/awaaz/config.rb', line 75 def no_decoders? @available_decoders.nil? || @available_decoders.empty? end |
#no_decoders_for_wav? ⇒ Boolean
Checks if there are no decoders available for handling WAV files.
This is the logical negation of #decoders_for_wav?.
97 98 99 |
# File 'lib/awaaz/config.rb', line 97 def no_decoders_for_wav? !decoders_for_wav? end |
#potential_decoders ⇒ Array<Symbol>
Lists all potential decoders that Awaaz can work with.
66 67 68 |
# File 'lib/awaaz/config.rb', line 66 def potential_decoders %i[mpg123 ffmpeg sox] end |
#sox? ⇒ Boolean
Checks if sox is available.
57 58 59 |
# File 'lib/awaaz/config.rb', line 57 def sox? decoder?(:sox) end |