Sha256: bc9683802705aafe416d1e3c0e9c03210ddf61b86702af1daee01b86204a30d0

Contents?: true

Size: 705 Bytes

Versions: 96

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

module Listen
  class Options
    def initialize(opts, defaults)
      @options = {}
      given_options = opts.dup
      defaults.each_key do |key|
        @options[key] = given_options.delete(key) || defaults[key]
      end

      given_options.empty? or raise ArgumentError, "Unknown options: #{given_options.inspect}"
    end

    # rubocop:disable Lint/MissingSuper
    def respond_to_missing?(name, *_)
      @options.has_key?(name)
    end

    def method_missing(name, *_)
      respond_to_missing?(name) or raise NameError, "Bad option: #{name.inspect} (valid:#{@options.keys.inspect})"
      @options[name]
    end
    # rubocop:enable Lint/MissingSuper
  end
end

Version data entries

96 entries across 95 versions & 6 rubygems

Version Path
harbr-2.8.1 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
listen-3.9.0 lib/listen/options.rb
harbr-0.2.10 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.2.9 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.2.8 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.2.7 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.2.6 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.2.5 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.2.4 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.2.3 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.2.2 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.2.1 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.96 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.95 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.94 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.93 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb