Class: EasyUpnp::OptionsBase

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_upnp/options_base.rb

Defined Under Namespace

Classes: Builder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, defaults, &block) ⇒ OptionsBase

Returns a new instance of OptionsBase.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/easy_upnp/options_base.rb', line 21

def initialize(options, defaults, &block)
  @options = defaults.merge(options)

  if block
    block_builder = Builder.new(defaults.keys)
    block.call(block_builder)
    @options = @options.merge(block_builder.options)
  end

  defaults.map do |k, v|
    define_singleton_method(k) do
      @options[k]
    end
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



19
20
21
# File 'lib/easy_upnp/options_base.rb', line 19

def options
  @options
end