Class: Hamloft::Options
- Inherits:
-
Object
- Object
- Hamloft::Options
- Defined in:
- lib/hamloft/options.rb
Instance Attribute Summary collapse
-
#asset_uri ⇒ Object
Returns the value of attribute asset_uri.
Class Method Summary collapse
-
.defaults ⇒ Object
The default option values.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Retrieve an option value.
-
#[]=(key, value) ⇒ Object
Set an option value.
-
#initialize(values = {}, &block) ⇒ Options
constructor
A new instance of Options.
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_uri ⇒ Object
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
.defaults ⇒ Object
The default option values.
10 11 12 |
# File 'lib/hamloft/options.rb', line 10 def self.defaults @defaults end |
Instance Method Details
#[](key) ⇒ Object
Retrieve an option value.
24 25 26 |
# File 'lib/hamloft/options.rb', line 24 def [](key) send key end |
#[]=(key, value) ⇒ Object
Set an option value.
31 32 33 |
# File 'lib/hamloft/options.rb', line 31 def []=(key, value) send "#{key}=", value end |