Class: Forecast::Config
- Inherits:
-
Object
- Object
- Forecast::Config
- Defined in:
- lib/forecast/config.rb
Instance Attribute Summary collapse
-
#adapters ⇒ Object
Returns the value of attribute adapters.
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#provider ⇒ Object
Returns the value of attribute provider.
-
#temp_scale ⇒ Object
Returns the value of attribute temp_scale.
-
#theme ⇒ Object
Returns the value of attribute theme.
-
#themes ⇒ Object
Returns the value of attribute themes.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load(pattern) ⇒ Object
Constructor Details
#initialize ⇒ Config
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/forecast/config.rb', line 6 def initialize @config_file = File.dirname(File.dirname(File.dirname(__FILE__))) + "/config/forecast.yml" self.load(File.dirname(__FILE__) + '/**/*.yml') self.load(@config_file) def theme if @theme != nil if @theme.is_a?(Hash) return @theme end if themes[@theme] != nil return themes[@theme] end end return @theme end end |
Instance Attribute Details
#adapters ⇒ Object
Returns the value of attribute adapters.
4 5 6 |
# File 'lib/forecast/config.rb', line 4 def adapters @adapters end |
#cache ⇒ Object
Returns the value of attribute cache.
4 5 6 |
# File 'lib/forecast/config.rb', line 4 def cache @cache end |
#conditions ⇒ Object
Returns the value of attribute conditions.
4 5 6 |
# File 'lib/forecast/config.rb', line 4 def conditions @conditions end |
#provider ⇒ Object
Returns the value of attribute provider.
4 5 6 |
# File 'lib/forecast/config.rb', line 4 def provider @provider end |
#temp_scale ⇒ Object
Returns the value of attribute temp_scale.
4 5 6 |
# File 'lib/forecast/config.rb', line 4 def temp_scale @temp_scale end |
#theme ⇒ Object
Returns the value of attribute theme.
4 5 6 |
# File 'lib/forecast/config.rb', line 4 def theme @theme end |
#themes ⇒ Object
Returns the value of attribute themes.
4 5 6 |
# File 'lib/forecast/config.rb', line 4 def themes @themes end |
Instance Method Details
#load(pattern) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/forecast/config.rb', line 27 def load(pattern) Dir.glob(pattern).sort{ |a, b| a.split(/\//).length <=> b.split(/\//).length}.reverse.each do |f| obj = YAML.load_file(f) if obj['forecast'] != nil obj['forecast'].each do |k, v| if respond_to?("#{k}") o = send("#{k}") if o.is_a?(Hash) v = deep_merge(o, v) end end send("#{k}=", v) if respond_to?("#{k}=") end end end end |