Class: Forecast::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/forecast/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig



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

#adaptersObject

Returns the value of attribute adapters.



4
5
6
# File 'lib/forecast/config.rb', line 4

def adapters
  @adapters
end

#cacheObject

Returns the value of attribute cache.



4
5
6
# File 'lib/forecast/config.rb', line 4

def cache
  @cache
end

#conditionsObject

Returns the value of attribute conditions.



4
5
6
# File 'lib/forecast/config.rb', line 4

def conditions
  @conditions
end

#providerObject

Returns the value of attribute provider.



4
5
6
# File 'lib/forecast/config.rb', line 4

def provider
  @provider
end

#temp_scaleObject

Returns the value of attribute temp_scale.



4
5
6
# File 'lib/forecast/config.rb', line 4

def temp_scale
  @temp_scale
end

#themeObject

Returns the value of attribute theme.



4
5
6
# File 'lib/forecast/config.rb', line 4

def theme
  @theme
end

#themesObject

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