Class: Barometer::WeatherService::WeatherBug

Inherits:
Object
  • Object
show all
Defined in:
lib/barometer/weather_services/weather_bug.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (WeatherBug) initialize(query, config = {})

A new instance of WeatherBug



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/barometer/weather_services/weather_bug.rb', line 17

def initialize(query, config={})
  @query = query
  @converted_query = nil
  @metric = config.fetch(:metric, true)

  @response = Response.new(metric)

  if config[:keys]
    @api_code = config[:keys][:code]
  end
end

Class Method Details

+ (Object) accepted_formats



9
10
11
# File 'lib/barometer/weather_services/weather_bug.rb', line 9

def self.accepted_formats
  [:short_zipcode, :coordinates]
end

+ (Object) call(query, config = {})



13
14
15
# File 'lib/barometer/weather_services/weather_bug.rb', line 13

def self.call(query, config={})
  WeatherService::WeatherBug.new(query, config).measure!
end

Instance Method Details

- (Object) measure!



29
30
31
32
33
34
35
36
37
38
# File 'lib/barometer/weather_services/weather_bug.rb', line 29

def measure!
  validate_key!
  convert_query!

  @requester = Barometer::Requester::WeatherBug.new(api_code, metric)
  fetch_and_parse_current
  fetch_and_parse_forecast

  response
end