Class: Spritely::Options
- Inherits:
-
Object
- Object
- Spritely::Options
- Defined in:
- lib/spritely/options.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(hash) ⇒ Options
constructor
A new instance of Options.
Constructor Details
#initialize(hash) ⇒ Options
Returns a new instance of Options.
7 8 9 10 11 12 13 |
# File 'lib/spritely/options.rb', line 7 def initialize(hash) = hash.inject({}) do |h, (key, value)| split_key = key.split('_') option = {split_key.pop.to_sym => value} h.deep_merge!(split_key.join('-') => option) end end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/spritely/options.rb', line 5 def end |
Instance Method Details
#[](key) ⇒ Object
15 16 17 |
# File 'lib/spritely/options.rb', line 15 def [](key) [key] || {} end |