Class: Spritely::Options

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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)
  @options = 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

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/spritely/options.rb', line 5

def options
  @options
end

Instance Method Details

#[](key) ⇒ Object



15
16
17
# File 'lib/spritely/options.rb', line 15

def [](key)
  options[key] || {}
end