Module: Forecast::Adapter
- Included in:
- Forecast::Adapters::OpenWeatherMapAdapter, Forecast::Adapters::WundergroundAdapter, Forecast::Adapters::YahooAdapter
- Defined in:
- lib/forecast/adapter.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
17 18 19 |
# File 'lib/forecast/adapter.rb', line 17 def self.included(base) base.extend(ClassMethods) end |
.instance ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/forecast/adapter.rb', line 21 def self.instance provider = Forecast.config.provider if provider.is_a?(Hash) adapter_name = provider['adapter'].to_s = provider.clone .delete('adapter') else adapter_name = provider = {} end if adapter_name adapter_classname = (adapter_name.to_s << "_adapter").split('_').collect!{ |w| w.capitalize }.join adapter_class = Object.const_get('Forecast').const_get("Adapters").const_get(adapter_classname) adapter_class.new() else puts 'no adapter provided' end end |
Instance Method Details
#config ⇒ Object
48 49 50 |
# File 'lib/forecast/adapter.rb', line 48 def config Forecast.config.adapters[self.class.slug] || {} end |
#initialize(options = {}) ⇒ Object
40 41 42 |
# File 'lib/forecast/adapter.rb', line 40 def initialize( = {}) = end |
#options ⇒ Object
44 45 46 |
# File 'lib/forecast/adapter.rb', line 44 def end |