Class: Hamloft::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/hamloft/options.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(values = {}, &block) ⇒ Options

Returns a new instance of Options.



16
17
18
19
20
# File 'lib/hamloft/options.rb', line 16

def initialize(values = {}, &block)
  defaults.each {|k, v| instance_variable_set :"@#{k}", v}
  values.reject {|k, v| !defaults.has_key?(k) || v.nil?}.each {|k, v| send("#{k}=", v)}
  yield if block_given?
end

Instance Attribute Details

#asset_uriObject

Returns the value of attribute asset_uri.



14
15
16
# File 'lib/hamloft/options.rb', line 14

def asset_uri
  @asset_uri
end

Class Method Details

.defaultsObject

The default option values.

Returns:

  • Hash



10
11
12
# File 'lib/hamloft/options.rb', line 10

def self.defaults
  @defaults
end

Instance Method Details

#[](key) ⇒ Object

Retrieve an option value.

Parameters:

  • key

    The value to retrieve.



24
25
26
# File 'lib/hamloft/options.rb', line 24

def [](key)
  send key
end

#[]=(key, value) ⇒ Object

Set an option value.

Parameters:

  • key

    The key to set.

  • value

    The value to set for the key.



31
32
33
# File 'lib/hamloft/options.rb', line 31

def []=(key, value)
  send "#{key}=", value
end