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-0.1.91 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.90 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.89 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.88 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.87 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.86 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.85 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.84 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.83 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.82 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.81 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.80 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.79 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.78 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.77 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.76 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.75 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.74 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.73 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb
harbr-0.1.72 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen/options.rb