Class: Driskell::Listen::Options
- Inherits:
-
Object
- Object
- Driskell::Listen::Options
- Defined in:
- lib/driskell-listen/options.rb
Instance Method Summary collapse
-
#initialize(opts, defaults) ⇒ Options
constructor
A new instance of Options.
- #method_missing(name, *_) ⇒ Object
Constructor Details
#initialize(opts, defaults) ⇒ Options
Returns a new instance of Options.
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/driskell-listen/options.rb', line 3 def initialize(opts, defaults) @options = {} = opts.dup defaults.keys.each do |key| @options[key] = .delete(key) || defaults[key] end return if .empty? msg = "Unknown options: #{.inspect}" Driskell::Listen::Logger.warn msg fail msg end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *_) ⇒ Object
17 18 19 20 21 |
# File 'lib/driskell-listen/options.rb', line 17 def method_missing(name, *_) return @options[name] if @options.key?(name) msg = "Bad option: #{name.inspect} (valid:#{@options.keys.inspect})" fail NameError, msg end |