mirror of
https://github.com/iritmaximus/brewery.git
synced 2026-10-12 19:13:49 +03:00
rubocop fixes
This commit is contained in:
+8
-9
@@ -3,13 +3,12 @@ class Place < OpenStruct
|
||||
[:id, :name, :status, :street, :city, :zip, :country, :overall]
|
||||
end
|
||||
|
||||
def self.weather location
|
||||
weather_api_key = self.api_key
|
||||
def self.weather(location)
|
||||
weather_api_key = api_key
|
||||
weather_api_url = "http://api.weatherstack.com/current"
|
||||
|
||||
response = HTTParty.get "#{weather_api_url}?access_key=#{weather_api_key}&query=#{location}"
|
||||
|
||||
#if response["success"]
|
||||
puts "#{weather_api_url}?access_key=#{weather_api_key}&query=#{location}"
|
||||
puts response.parsed_response
|
||||
data = response.parsed_response["current"]
|
||||
@@ -17,11 +16,10 @@ class Place < OpenStruct
|
||||
return
|
||||
end
|
||||
|
||||
weather = self.parse_weather_data data
|
||||
return weather
|
||||
parse_weather_data data
|
||||
end
|
||||
|
||||
def self.parse_weather_data data
|
||||
def self.parse_weather_data(data)
|
||||
temperature = data["temperature"]
|
||||
weather_icon = data["weather_icons"][0]
|
||||
weather_descriptions = data["weather_descriptions"][0]
|
||||
@@ -29,14 +27,15 @@ class Place < OpenStruct
|
||||
wind_direction = data["wind_dir"]
|
||||
wind_speed = data["wind_speed"]
|
||||
wind = { direction: wind_direction, speed: wind_speed }
|
||||
weather = { temperature: temperature, wind: wind, weather_icon: weather_icon}
|
||||
return weather
|
||||
{ temperature:, wind:, weather_icon: }
|
||||
end
|
||||
|
||||
def self.api_key
|
||||
return nil if Rails.env.test?
|
||||
|
||||
key = Rails.application.credentials.weatherstack_api_key
|
||||
raise 'WEATHERSTACK_API_KEY env variable not defined in credentials' if key.nil?
|
||||
return key
|
||||
|
||||
key
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,8 +24,10 @@ class BeermappingApi
|
||||
|
||||
def self.key
|
||||
return nil if Rails.env.test?
|
||||
|
||||
key = Rails.application.credentials.beermapping_api_key
|
||||
raise 'BEERMAPPING_API_KEY env variable not defined' if key.nil?
|
||||
return key
|
||||
|
||||
key
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user