Module: Forecast::Adapter
- Included in:
- Forecast::Adapters::ForecastIoAdapter, 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
- #current(latitude, longitude) ⇒ Object
- #daily(latitude, longitude) ⇒ Object
- #hourly(latitude, longitude) ⇒ Object
- #initialize(options = {}) ⇒ Object
Class Method Details
.included(base) ⇒ Object
16 17 18 |
# File 'lib/forecast/adapter.rb', line 16 def self.included(base) base.extend(ClassMethods) end |
.instance ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/forecast/adapter.rb', line 20 def self.instance = {} provider = Forecast.config.provider if provider.is_a?(String) || provider.is_a?(Symbol) adapter_name = provider.to_sym elsif provider.is_a?(Hash) adapter_name = provider[:adapter].to_s = provider.clone .delete('adapter') end if adapter_name if Forecast.config.adapters != nil && Forecast.config.adapters.has_key?(adapter_name) = .merge(Forecast.config.adapters[adapter_name]) end 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 'Adapter not found' end end |
Instance Method Details
#current(latitude, longitude) ⇒ Object
47 48 |
# File 'lib/forecast/adapter.rb', line 47 def current(latitude, longitude) end |
#daily(latitude, longitude) ⇒ Object
53 54 |
# File 'lib/forecast/adapter.rb', line 53 def daily(latitude, longitude) end |
#hourly(latitude, longitude) ⇒ Object
50 51 |
# File 'lib/forecast/adapter.rb', line 50 def hourly(latitude, longitude) end |
#initialize(options = {}) ⇒ Object
42 43 44 45 |
# File 'lib/forecast/adapter.rb', line 42 def initialize( = {}) = ({cache: Forecast.config.cache}).merge() @http = Http.new({cache: [:cache]}) end |